summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/kernel
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-09-04 06:02:25 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-09-04 06:02:25 +0000
commit763f84a6dace6af3d8637d12dd9cd2f6f69b46ab (patch)
tree75ac4ce391c59a62f23cbd02ffae54e3134376cc /sca-cpp/trunk/kernel
parentad5eccea058713a2816ca95f7f4392fe0ab03fb0 (diff)
Build with Clang/LLVM when available.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1164964 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/kernel')
-rw-r--r--sca-cpp/trunk/kernel/config.hpp37
-rw-r--r--sca-cpp/trunk/kernel/fstream.hpp2
-rw-r--r--sca-cpp/trunk/kernel/gc.hpp37
-rw-r--r--sca-cpp/trunk/kernel/hash.hpp2
-rw-r--r--sca-cpp/trunk/kernel/lambda-test.cpp6
5 files changed, 52 insertions, 32 deletions
diff --git a/sca-cpp/trunk/kernel/config.hpp b/sca-cpp/trunk/kernel/config.hpp
index f700829fa5..5b447e116b 100644
--- a/sca-cpp/trunk/kernel/config.hpp
+++ b/sca-cpp/trunk/kernel/config.hpp
@@ -34,10 +34,36 @@
/**
* Platform configuration and debug functions.
*/
-
namespace tuscany
{
+/**
+ * Attribute used to mark unused parameters.
+ */
+#ifndef unused
+#define unused __attribute__ ((unused))
+#endif
+
+/**
+ * Compiler feature detection.
+ */
+#ifdef __clang__
+
+#if __has_feature(cxx_lambdas)
+#define HAS_CXX0X_LAMBDAS 1
+#endif
+
+#else
+
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)
+#define HAS_CXX0X_LAMBDAS 1
+#endif
+
+#endif
+
+/**
+ * Debug utilities.
+ */
#ifdef WANT_MAINTAINER_MODE
/**
@@ -46,7 +72,7 @@ namespace tuscany
//#define WANT_MAINTAINER_WATCH
/**
- * Increment / decrement a debug counter.
+ * Increment/decrement a debug counter.
*/
bool debug_inc(long int& c) {
c++;
@@ -65,12 +91,5 @@ bool debug_dec(long int& c) {
#endif
-/**
- * Attribute used to mark unused parameters.
- */
-#ifndef unused
-#define unused __attribute__ ((unused))
-#endif
-
}
#endif /* tuscany_config_hpp */
diff --git a/sca-cpp/trunk/kernel/fstream.hpp b/sca-cpp/trunk/kernel/fstream.hpp
index d57de2d76a..6888e7d14d 100644
--- a/sca-cpp/trunk/kernel/fstream.hpp
+++ b/sca-cpp/trunk/kernel/fstream.hpp
@@ -164,7 +164,7 @@ public:
logfstream(FILE* file, const string& type) : file(file), type(type), owner(false), head(false) {
}
- logfstream(const logfstream& os) : file(os.file), type(type), owner(false), head(os.head) {
+ logfstream(const logfstream& os) : file(os.file), type(os.type), owner(false), head(os.head) {
}
~logfstream() {
diff --git a/sca-cpp/trunk/kernel/gc.hpp b/sca-cpp/trunk/kernel/gc.hpp
index 30cc637388..28ca80edc9 100644
--- a/sca-cpp/trunk/kernel/gc.hpp
+++ b/sca-cpp/trunk/kernel/gc.hpp
@@ -47,7 +47,7 @@ namespace tuscany
*/
bool assertOrFail(const bool expr) {
if (!expr)
- *(char*)NULL = '\0';
+ abort();
return true;
}
@@ -183,7 +183,8 @@ public:
class gc_pool_stack_t {
public:
gc_pool_stack_t() {
- pthread_key_create(&key, NULL);
+ int rc = pthread_key_create(&key, NULL);
+ assertOrFail(rc == 0);
}
operator apr_pool_t*() const {
@@ -204,21 +205,6 @@ apr_pool_t* gc_pool_stack = NULL;
#endif
/**
- * Return the current memory pool.
- */
-apr_pool_t* gc_current_pool() {
- apr_pool_t* apr_pool = gc_pool_stack;
- if (apr_pool != NULL)
- return apr_pool;
-
- // Create a parent pool for the current thread
- apr_pool_create(&apr_pool, NULL);
- assertOrFail(apr_pool != NULL);
- gc_pool_stack = apr_pool;
- return apr_pool;
-}
-
-/**
* Push a pool onto the stack.
*/
apr_pool_t* gc_push_pool(apr_pool_t* pool) {
@@ -237,6 +223,21 @@ apr_pool_t* gc_pop_pool(apr_pool_t* pool) {
}
/**
+ * Return the current memory pool.
+ */
+apr_pool_t* gc_current_pool() {
+ apr_pool_t* p = gc_pool_stack;
+ if (p != NULL)
+ return p;
+
+ // Create a parent pool for the current thread
+ apr_pool_create(&p, NULL);
+ assertOrFail(p != NULL);
+ gc_push_pool(p);
+ return p;
+}
+
+/**
* A memory pool scope, used to setup a scope in which a particular pool
* will be used for all allocations.
*/
@@ -302,7 +303,7 @@ template<typename T> apr_status_t gc_pool_acleanup(void* v) {
}
template<typename T> T* gc_anew(apr_pool_t* p, size_t n) {
- size_t* gc_anew_ptr = static_cast<size_t*>(apr_palloc(p, sizeof(size_t) + sizeof(T[n])));
+ size_t* gc_anew_ptr = static_cast<size_t*>(apr_palloc(p, sizeof(size_t) + sizeof(T) * n));
assertOrFail(gc_anew_ptr != NULL);
*gc_anew_ptr = n;
apr_pool_cleanup_register(p, gc_anew_ptr, gc_pool_acleanup<T>, apr_pool_cleanup_null) ;
diff --git a/sca-cpp/trunk/kernel/hash.hpp b/sca-cpp/trunk/kernel/hash.hpp
index 9de13dd690..993511e3c2 100644
--- a/sca-cpp/trunk/kernel/hash.hpp
+++ b/sca-cpp/trunk/kernel/hash.hpp
@@ -122,7 +122,7 @@ const unsigned int murmurhash(const char* key, const size_t klen) {
// Mix 4 bytes at a time into the hash
const unsigned char* data = (const unsigned char*)key;
while(len >= 4) {
- unsigned int k = *(unsigned int*)data;
+ unsigned int k = *(unsigned int*)(void*)data;
k *= m;
k ^= k >> r;
k *= m;
diff --git a/sca-cpp/trunk/kernel/lambda-test.cpp b/sca-cpp/trunk/kernel/lambda-test.cpp
index a72f01fb43..e17cf57e67 100644
--- a/sca-cpp/trunk/kernel/lambda-test.cpp
+++ b/sca-cpp/trunk/kernel/lambda-test.cpp
@@ -31,7 +31,7 @@
namespace tuscany {
-#ifdef WANT_GCC45
+#ifdef HAS_CXX0X_LAMBDAS
const lambda<const int(const int)> inc(const int i) {
return [=](const int x)->const int {
@@ -89,11 +89,11 @@ bool testCppPerf() {
int main() {
tuscany::cout << "Testing..." << tuscany::endl;
-#ifdef WANT_GCC45
+#ifdef HAS_CXX0X_LAMBDAS
tuscany::testLambda();
tuscany::testCppPerf();
#else
- tuscany::cout << "Skipped GCC 4.5 tests" << tuscany::endl;
+ tuscany::cout << "Skipped C++0x lambda tests" << tuscany::endl;
#endif
tuscany::cout << "OK" << tuscany::endl;