Author: jsdelfino
Date: Tue Sep 20 04:45:31 2011
New Revision: 1172977
URL: http://svn.apache.org/viewvc?rev=1172977&view=rev
Log:
Fix stack overflow on Mac OS X.
Modified:
tuscany/sca-cpp/trunk/configure.ac
tuscany/sca-cpp/trunk/kernel/sstream.hpp
tuscany/sca-cpp/trunk/kernel/value.hpp
tuscany/sca-cpp/trunk/modules/http/httpd-conf
tuscany/sca-cpp/trunk/modules/http/httpd-event-conf
tuscany/sca-cpp/trunk/modules/http/httpd-worker-conf
Modified: tuscany/sca-cpp/trunk/configure.ac
URL:
http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/configure.ac?rev=1172977&r1=1172976&r2=1172977&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/configure.ac (original)
+++ tuscany/sca-cpp/trunk/configure.ac Tue Sep 20 04:45:31 2011
@@ -39,6 +39,8 @@ if test "${CXX}" = ""; then
else
AM_CONDITIONAL([WANT_LLVM], false)
fi
+else
+ AM_CONDITIONAL([WANT_LLVM], false)
fi
AC_PROG_CXX
AC_PROG_AWK
Modified: tuscany/sca-cpp/trunk/kernel/sstream.hpp
URL:
http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/sstream.hpp?rev=1172977&r1=1172976&r2=1172977&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/sstream.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/sstream.hpp Tue Sep 20 04:45:31 2011
@@ -43,6 +43,18 @@ void* stream_memcpy(void* t, const void*
}
/**
+ * Write a list of strings into a buffer.
+ */
+const bool writeList(const list<string>& l, char* buf) {
+ if (isNil(l))
+ return true;
+ const string c = car(l);
+ char* b = buf - length(c);
+ memcpy(b, c_str(c), length(c));
+ return writeList(cdr(l), b);
+}
+
+/**
* Output stream backed by a char buffer.
*/
class ostringstream : public ostream {
@@ -83,22 +95,13 @@ public:
}
private:
- static const bool strHelper(const list<string> l, char* buf) {
- if (isNil(l))
- return true;
- const string c = car(l);
- char* b = buf - length(c);
- memcpy(b, c_str(c), length(c));
- return strHelper(cdr(l), b);
- }
-
const string str() {
if (isNil(buf))
return string();
string s;
s.len = len;
s.buf = gc_cnew(s.len + 1);
- strHelper(buf, s.buf + len);
+ writeList(buf, s.buf + len);
s.buf[s.len] = '\0';
return s;
}
Modified: tuscany/sca-cpp/trunk/kernel/value.hpp
URL:
http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/value.hpp?rev=1172977&r1=1172976&r2=1172977&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/value.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/value.hpp Tue Sep 20 04:45:31 2011
@@ -448,15 +448,30 @@ const string watchValue(const value& v)
#endif
/**
+ * Write an escape string to a buffer.
+ */
+const char* escapestr(const char* s, char* buf) {
+ if (*s == '\0') {
+ *buf = '\0';
+ return buf;
+ }
+ if (*s == '\\' || *s == '"') {
+ *buf = '\\';
+ *(buf + 1) = *s;
+ return escapestr(s + 1, buf + 2);
+ }
+ *buf = *s;
+ return escapestr(s + 1, buf + 1);
+}
+
+/**
* Write an escaped string value to a stream.
*/
-ostream& escvwrite(const char* s, ostream& out) {
- if (*s == '\0')
- return out;
- if (*s == '\\' || *s == '"')
- out << '\\';
- out << *s;
- return escvwrite(s + 1, out);
+ostream& escvwrite(const string& str, ostream& out) {
+ char* buf = gc_cnew(length(str) * 2 + 1);
+ escapestr(c_str(str), buf);
+ out << buf;
+ return out;
}
/**
@@ -472,7 +487,7 @@ ostream& operator<<(ostream& out, const
return out << v.str()();
case value::String:
out << '\"';
- escvwrite(c_str(v.str()()), out);
+ escvwrite(v.str()(), out);
return out << '\"';
case value::Number:
return out << v.num()();
Modified: tuscany/sca-cpp/trunk/modules/http/httpd-conf
URL:
http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/http/httpd-conf?rev=1172977&r1=1172976&r2=1172977&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/http/httpd-conf (original)
+++ tuscany/sca-cpp/trunk/modules/http/httpd-conf Tue Sep 20 04:45:31 2011
@@ -183,6 +183,16 @@ LoadModule mpm_prefork_module ${modules_
EOF
+uname=`uname -s`
+if [ $uname = "Darwin" ]; then
+ cat >>$root/conf/mpm.conf <<EOF
+# Generated by: httpd-conf $*
+# Set thread stack size
+ThreadStackSize 2097152
+
+EOF
+fi
+
# Generate modules list
cat >$root/conf/modules.conf <<EOF
# Generated by: httpd-conf $*
Modified: tuscany/sca-cpp/trunk/modules/http/httpd-event-conf
URL:
http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/http/httpd-event-conf?rev=1172977&r1=1172976&r2=1172977&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/http/httpd-event-conf (original)
+++ tuscany/sca-cpp/trunk/modules/http/httpd-event-conf Tue Sep 20 04:45:31 2011
@@ -33,3 +33,13 @@ LoadModule mpm_event_module ${modules_pr
EOF
+uname=`uname -s`
+if [ $uname = "Darwin" ]; then
+ cat >>$root/conf/mpm.conf <<EOF
+# Generated by: httpd-event-conf $*
+# Set thread stack size
+ThreadStackSize 2097152
+
+EOF
+fi
+
Modified: tuscany/sca-cpp/trunk/modules/http/httpd-worker-conf
URL:
http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/http/httpd-worker-conf?rev=1172977&r1=1172976&r2=1172977&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/http/httpd-worker-conf (original)
+++ tuscany/sca-cpp/trunk/modules/http/httpd-worker-conf Tue Sep 20 04:45:31
2011
@@ -33,3 +33,13 @@ LoadModule mpm_worker_module ${modules_p
EOF
+uname=`uname -s`
+if [ $uname = "Darwin" ]; then
+ cat >>$root/conf/mpm.conf <<EOF
+# Generated by: httpd-event-conf $*
+# Set thread stack size
+ThreadStackSize 2097152
+
+EOF
+fi
+