Permalink
Browse files

Merge branches 'bugfixes', 'syslog' and 'datetime', remote branch 'or…

…igin/misc'
  • Loading branch information...
5 parents caa03d7 + 3f0bae6 + 4df0e90 + 29693fa + 46bac6d commit c768f642eb6c609414b4f6a6daf112c0e6c5f8aa root committed Jun 17, 2011
Showing with 52,112 additions and 18,104 deletions.
  1. +1 −0 doc/options.compiled
  2. +0 −1 doc/options.compiler
  3. +112 −0 scripts/compile.sh
  4. +6 −0 scripts/hphp.sh
  5. +6 −0 scripts/hphpi.sh
  6. +4 −0 scripts/setup.sh
  7. +1 −1 src/compiler/analysis/variable_table.cpp
  8. +4 −32 src/compiler/code_generator.cpp
  9. +0 −1 src/compiler/code_generator.h
  10. +1 −8 src/compiler/option.cpp
  11. +0 −1 src/compiler/option.h
  12. +1 −1 src/idl/array.idl.php
  13. +14 −3 src/idl/base.php
  14. +531 −1 src/idl/datetime.idl.php
  15. +3 −3 src/runtime/base/execution_context.cpp
  16. +4 −0 src/runtime/base/memory/smart_allocator.cpp
  17. +1 −0 src/runtime/base/memory/smart_allocator.h
  18. +1 −1 src/runtime/base/object_data.h
  19. +1 −0 src/runtime/base/runtime_option.cpp
  20. +6 −2 src/runtime/base/server/http_server.cpp
  21. +1 −1 src/runtime/base/server/http_server.h
  22. +82 −43 src/runtime/base/time/datetime.cpp
  23. +53 −2 src/runtime/base/time/datetime.h
  24. +95 −19 src/runtime/base/time/timezone.cpp
  25. +26 −2 src/runtime/base/time/timezone.h
  26. +2 −2 src/runtime/base/type_array.cpp
  27. +1 −1 src/runtime/base/type_array.h
  28. +2 −0 src/runtime/base/type_variant.cpp
  29. +3 −0 src/runtime/base/types.h
  30. +25 −24 src/runtime/base/util/extended_logger.cpp
  31. +3 −3 src/runtime/base/util/extended_logger.h
  32. +0 −4 src/runtime/base/zend/zend_html.cpp
  33. +1 −1 src/runtime/ext/ext_array.cpp
  34. +1 −1 src/runtime/ext/ext_array.h
  35. +220 −18 src/runtime/ext/ext_datetime.cpp
  36. +129 −9 src/runtime/ext/ext_datetime.h
  37. +1 −1 src/runtime/ext/ext_soap.cpp
  38. +1 −1 src/runtime/ext/profile/extprofile_array.h
  39. +70 −4 src/runtime/ext/profile/extprofile_datetime.h
  40. +1 −1 src/runtime/ext/soap/encoding.cpp
  41. +1 −1 src/runtime/ext/soap/packet.cpp
  42. +1 −1 src/runtime/ext/soap/schema.cpp
  43. +2 −2 src/runtime/ext/soap/sdl.cpp
  44. +10 −8 src/runtime/ext/soap/xml.cpp
  45. +3 −2 src/runtime/ext/soap/xml.h
  46. +1 −1 src/system/array.inc
  47. +20 −8 src/system/datetime.inc
  48. +10 −0 src/test/test_ext_array.cpp
  49. +201 −5 src/test/test_ext_datetime.cpp
  50. +14 −0 src/test/test_ext_datetime.h
  51. +0 −2 src/third_party/libmbfl/.gitignore
  52. +303 −0 src/third_party/libmbfl/filters/8859-1.TXT
  53. +303 −0 src/third_party/libmbfl/filters/8859-10.TXT
  54. +297 −0 src/third_party/libmbfl/filters/8859-11.TXT
  55. +299 −0 src/third_party/libmbfl/filters/8859-13.TXT
  56. +301 −0 src/third_party/libmbfl/filters/8859-14.TXT
  57. +303 −0 src/third_party/libmbfl/filters/8859-15.TXT
  58. +299 −0 src/third_party/libmbfl/filters/8859-16.TXT
  59. +303 −0 src/third_party/libmbfl/filters/8859-2.TXT
  60. +296 −0 src/third_party/libmbfl/filters/8859-3.TXT
  61. +303 −0 src/third_party/libmbfl/filters/8859-4.TXT
  62. +303 −0 src/third_party/libmbfl/filters/8859-5.TXT
  63. +260 −0 src/third_party/libmbfl/filters/8859-6.TXT
  64. +308 −0 src/third_party/libmbfl/filters/8859-7.TXT
  65. +270 −0 src/third_party/libmbfl/filters/8859-8.TXT
  66. +307 −0 src/third_party/libmbfl/filters/8859-9.TXT
  67. +23,735 −0 src/third_party/libmbfl/mbfl/EastAsianWidth.txt
  68. +1 −1 src/third_party/timelib/CMakeLists.txt
  69. +2 −1 src/third_party/timelib/README
  70. +15 −0 src/third_party/timelib/dow.c
  71. +65 −0 src/third_party/timelib/interval.c
  72. +18,821 −17,126 src/third_party/timelib/parse_date.c
  73. +507 −20 src/third_party/timelib/parse_date.re
  74. +1,161 −0 src/third_party/timelib/parse_iso_intervals.c
  75. +555 −0 src/third_party/timelib/parse_iso_intervals.re
  76. +50 −7 src/third_party/timelib/parse_tz.c
  77. +78 −12 src/third_party/timelib/timelib.c
  78. +24 −2 src/third_party/timelib/timelib.h
  79. +1 −1 src/third_party/timelib/timelib.m4
  80. +41 −29 src/third_party/timelib/timelib_structs.h
  81. +697 −636 src/third_party/timelib/timezonedb.h
  82. +131 −12 src/third_party/timelib/tm2unixtime.c
  83. +1 −1 src/third_party/timelib/unixtime2tm.c
  84. +44 −23 src/util/logger.cpp
  85. +14 −6 src/util/logger.h
  86. +28 −5 src/util/util.cpp
  87. +9 −0 src/util/util.h
View
@@ -47,6 +47,7 @@ flood error logs.
# error log settings
UseLogFile = true
File = filename
+ UseSyslog = false
# access log settings
AccessLogDefaultFormat = %h %l %u %t \"%r\" %>s %b
View
@@ -264,7 +264,6 @@ Under "CodeGeneration", one can specify alternative name prefixes that are
used in different places of code generation.
- IdPrefix
-- LabelEscape
- LambdaPrefix
- FunctionPrefix
- BuiltinFunctionPrefix
View
@@ -0,0 +1,112 @@
+#!/bin/bash -e
+
+set -e
+
+SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
+
+function wrong_args {
+ echo "Usage: $(basename "$0") [OPTION]... BASE_SOURCE_DIR..."
+ echo "Options:"
+ echo " -i SED_COMMAND_FILE"
+ echo " -c CONFIG_FILE"
+ echo " -v INLINE_OPTION"
+ echo " -o OUT_DIR"
+ echo " -p PROGRAM_NAME"
+ echo " -C CLUSTERS"
+ echo " -j JOBS"
+ exit 1
+}
+
+SED_CMD_FILES=()
+OPTIONS=()
+OUT_DIR="hiphop-out"
+CLUSTERS=0
+JOBS=1
+PROGRAM_NAME="program"
+while getopts "i:c:v:o:p:C:j:" OPTION; do
+ case $OPTION in
+ i)
+ SED_CMD_FILES[${#SED_CMD_FILES[@]}]="$OPTARG"
+ ;;
+ c|v)
+ OPTIONS[${#OPTIONS[@]}]="-$OPTION"
+ OPTIONS[${#OPTIONS[@]}]="$OPTARG"
+ ;;
+ o)
+ OUT_DIR="$OPTARG"
+ ;;
+ p)
+ PROGRAM_NAME="$OPTARG"
+ ;;
+ C)
+ CLUSTERS="$OPTARG"
+ ;;
+ j)
+ JOBS="$OPTARG"
+ ;;
+ ?)
+ wrong_args
+ ;;
+ esac
+done
+shift $(($OPTIND - 1))
+if [ $# -lt 1 ]; then
+ echo "No source directory specified"
+ wrong_args
+fi
+COMPILE_LIST="$OUT_DIR/compile.lst"
+
+echo -n "Setting up... "
+. "$SCRIPT_DIR/setup.sh"
+if [ -d "$OUT_DIR" ]; then
+ echo "ERROR: output directory \"$OUT_DIR\" already exists"
+ exit 1
+fi
+
+mkdir "$OUT_DIR"
+cp "$HPHP_LIB/CMakeLists.base.txt" "$OUT_DIR/CMakeLists.txt"
+
+TIMEFORMAT="DONE (%3lR)"
+echo "DONE"
+
+echo -n "Generating source file list... "
+time find $@ -name "*.php" -o -name "*.inc" > "$COMPILE_LIST"
+for SED_CMD_FILE in "${SED_CMD_FILES[@]}"; do
+ sed -i -f "$SED_CMD_FILE" "$COMPILE_LIST"
+done
+echo "Found $(wc -l "$COMPILE_LIST" | cut -d' ' -f1) source files"
+
+"$HPHP_HOME/src/hphp/hphp" -t cpp -o "$OUT_DIR" -l 3 \
+ --force 1 --parse-on-demand 0 \
+ --cluster-count "$CLUSTERS" \
+ --input-list "$COMPILE_LIST" \
+ --program "$PROGRAM_NAME" \
+ --opts "deadcode,localcopy,string,cflow" \
+ "${OPTIONS[@]}"
+
+cd "$OUT_DIR"
+
+echo "Checking for distcc support"
+if [ -e "/etc/distcc/hosts" ]; then
+ echo "Compiling with distcc"
+
+ echo "Run cmake..."
+ TIMEFORMAT="cmake took %3lR (%3lU user, %3lS system)"
+ time DISTCC_FALLBACK=0 HOSTCC='distcc gcc' CC='distcc gcc' CXX='distcc g++' \
+ cmake -D "PROGRAM_NAME:string=$PROGRAM_NAME" .
+
+ echo "Run make..."
+ TIMEFORMAT="make took %3lR (%3lU user, %3lS system)"
+ time DISTCC_FALLBACK=0 make -j "$JOBS" \
+ HOSTCC='distcc gcc' CC='distcc gcc' CXX='distcc g++' "$PROGRAM_NAME/fast"
+else
+ echo "You have no distcc support, (/etc/distcc/hosts not found)"
+
+ echo "Run cmake..."
+ TIMEFORMAT="cmake took %3lR (%3lU user, %3lS system)"
+ time cmake -D "PROGRAM_NAME:string=$PROGRAM_NAME" .
+
+ echo "Run make..."
+ TIMEFORMAT="make took %3lR (%3lU user, %3lS system)"
+ time make -j "$JOBS" "$PROGRAM_NAME/fast"
+fi
View
@@ -0,0 +1,6 @@
+#!/bin/bash -e
+
+set -e
+
+. "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
+"$HPHP_HOME/src/hphp/hphp" $@
View
@@ -0,0 +1,6 @@
+#!/bin/bash -e
+
+set -e
+
+. "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
+"$HPHP_HOME/src/hphpi/hphpi" $@
View
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+export HPHP_HOME="$(cd "$(dirname "${BASH_SOURCE[0]}")/.."; pwd)"
+export HPHP_LIB="$HPHP_HOME/bin"
@@ -225,7 +225,7 @@ const char *VariableTable::getVariablePrefix(const Symbol *sym) const {
}
}
- if (sym->isHidden() && !sym->isParameter()) {
+ if (sym && sym->isHidden() && !sym->isParameter()) {
return Option::HiddenVariablePrefix;
}
@@ -211,20 +211,6 @@ void CodeGenerator::namespaceEnd() {
printf("}\n");
}
-std::string CodeGenerator::getFormattedName(const std::string &file) {
- char *fn = strdup(file.c_str());
- int len = strlen(fn);
- assert(len == (int)file.size());
- for (int i = 0; i < len; i++) {
- if (!isalnum(fn[i])) fn[i] = '_';
- }
- string formatted = fn;
- free(fn);
- int hash = hash_string(file.data(), file.size());
- formatted += boost::str(boost::format("%08x") % hash);
- return formatted;
-}
-
bool CodeGenerator::ensureInNamespace() {
if (m_inNamespace) return false;
namespaceBegin();
@@ -238,15 +224,16 @@ bool CodeGenerator::ensureOutOfNamespace() {
}
void CodeGenerator::headerBegin(const std::string &file) {
- string formatted = getFormattedName(file);
+ string formatted = Util::escapeIdentifier(file);
printf("\n");
printf("#ifndef __GENERATED_%s__\n", formatted.c_str());
printf("#define __GENERATED_%s__\n", formatted.c_str());
printf("\n");
}
void CodeGenerator::headerEnd(const std::string &file) {
- string formatted = getFormattedName(file);
+ string formatted = Util::escapeIdentifier(file);
+
printf("\n");
printf("#endif // __GENERATED_%s__\n", formatted.c_str());
}
@@ -350,22 +337,7 @@ const char *CodeGenerator::getGlobals(AnalysisResultPtr ar) {
}
std::string CodeGenerator::formatLabel(const std::string &name) {
- string ret;
- ret.reserve(name.size());
- for (size_t i = 0; i < name.size(); i++) {
- unsigned char ch = name[i];
- if ((ch >= 'a' && ch <= 'z') ||
- (ch >= 'A' && ch <= 'Z') ||
- (ch >= '0' && ch <= '9') || ch == '_') {
- ret += ch;
- } else {
- char buf[10];
- snprintf(buf, sizeof(buf), "%s%02X", Option::LabelEscape.c_str(),
- (int)ch);
- ret += buf;
- }
- }
- return ret;
+ return Util::escapeIdentifier(name);
}
std::string CodeGenerator::escapeLabel(const std::string &name,
@@ -304,7 +304,6 @@ class CodeGenerator {
void print(const char *msg, bool indent = true);
void printSubstring(const char *start, int length);
void printIndent();
- std::string getFormattedName(const std::string &file);
};
#define STR(x) #x
View
@@ -76,10 +76,8 @@ map<string, string> Option::FunctionSections;
#if defined(HPHP_OSS)
string Option::IdPrefix = "___";
-string Option::LabelEscape = "___";
#else
string Option::IdPrefix = "$$";
-string Option::LabelEscape = "$";
#endif
string Option::LambdaPrefix = "df_";
@@ -310,7 +308,6 @@ void Option::Load(Hdf &config) {
}
READ_CG_OPTION(IdPrefix);
- READ_CG_OPTION(LabelEscape);
READ_CG_OPTION(LambdaPrefix);
READ_CG_OPTION(FunctionPrefix);
READ_CG_OPTION(BuiltinFunctionPrefix);
@@ -523,11 +520,7 @@ std::string Option::MangleFilename(const std::string &name, bool id) {
string ret = UserFilePrefix;
ret += name;
- if (id) {
- Util::replaceAll(ret, "/", "$");
- Util::replaceAll(ret, "-", "_");
- Util::replaceAll(ret, ".", "_");
- }
+ if (id) ret = Util::escapeIdentifier(ret);
return ret;
}
View
@@ -210,7 +210,6 @@ class Option {
* A somewhat unique prefix for system identifiers.
*/
static std::string IdPrefix;
- static std::string LabelEscape;
static std::string LambdaPrefix;
static std::string Tab;
View
@@ -422,7 +422,7 @@
array(
'name' => "search_value",
'type' => Variant,
- 'value' => "null_variant",
+ 'value' => "not_given_variant",
'desc' => "If specified, then only keys containing these values are returned.",
),
array(
View
@@ -397,14 +397,14 @@ function fprintType($f, $type) {
function get_serialized_default($s) {
// These values are special and cannot be returned by
// ReflectionParameter::getDefaultValue().
- if ($s == 'TimeStamp::Current()' ||
+ if ($s == 'TimeStamp::Current()' || $s == 'not_given_variant' ||
preg_match('/^k_SQLITE3_/', $s)) {
return "\x01";
}
if (preg_match('/^".*"$/', $s) ||
preg_match('/^[\-0-9.]+$/', $s) ||
- preg_match('/^0x[0-9a-fA-F]+$/', $s) ||
+ preg_match('/^-?0x[0-9a-fA-F]+$/', $s) ||
preg_match('/^(true|false|null)$/', $s)
) {
return serialize(eval("return $s;"));
@@ -424,8 +424,19 @@ function get_serialized_default($s) {
if ($s == 'RAND_MAX') {
return serialize(getrandmax());
}
+ // Use literal values below to avoid possible overflows to floating point
+ // when doing calculations
+ if ($s == 'INT_MIN') {
+ return serialize(-0x80000000);
+ }
if ($s == 'INT_MAX') {
- return serialize((1 << 31) - 1);
+ return serialize(0x7FFFFFFF);
+ }
+ if ($s == 'LLONG_MIN') {
+ return serialize(-0x8000000000000000);
+ }
+ if ($s == 'LLONG_MAX') {
+ return serialize(0x7FFFFFFFFFFFFFFF);
}
throw new Exception("Unable to serialize default value: [$s]");
}
Oops, something went wrong.

0 comments on commit c768f64

Please sign in to comment.