Commit 80f24a34 authored by Kenton Varda's avatar Kenton Varda

tweaks

parent bdb86c21
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
#warning "This library requires at least GCC 4.7." #warning "This library requires at least GCC 4.7."
#endif #endif
#endif #endif
#elif defined(_MSC_VER)
#warning "As of June 2013, Visual Studio's C++11 support was hopelessly behind what is needed to compile this code."
#endif #endif
// ======================================================================================= // =======================================================================================
...@@ -60,19 +62,29 @@ typedef unsigned char byte; ...@@ -60,19 +62,29 @@ typedef unsigned char byte;
// ======================================================================================= // =======================================================================================
// Common macros, especially for common yet compiler-specific features. // Common macros, especially for common yet compiler-specific features.
#ifndef KJ_NO_RTTI // Detect whether RTTI and exceptions are enabled, assuming they are unless we have specific
#ifdef __GNUC__ // evidence to the contrary. Clients can always define KJ_NO_RTTI or KJ_NO_EXCEPTIONS explicitly
#if !__GXX_RTTI // to override these checks.
#define KJ_NO_RTTI #ifdef __GNUC__
#endif #if !defined(KJ_NO_RTTI) && !__GXX_RTTI
#define KJ_NO_RTTI 1
#endif
#if !defined(KJ_NO_EXCEPTIONS) && !__EXCEPTIONS
#define KJ_NO_EXCEPTIONS 1
#endif
#elif defined(_MSC_VER)
#if !defined(KJ_NO_RTTI) && !defined(_CPPRTTI)
#define KJ_NO_RTTI 1
#endif
#if !defined(KJ_NO_EXCEPTIONS) && !defined(_CPPUNWIND)
#define KJ_NO_EXCEPTIONS 1
#endif #endif
#endif #endif
#define KJ_DISALLOW_COPY(classname) \ #define KJ_DISALLOW_COPY(classname) \
classname(const classname&) = delete; \ classname(const classname&) = delete; \
classname& operator=(const classname&) = delete classname& operator=(const classname&) = delete
// Deletes the implicit copy constructor and assignment operator.
#define KJ_OFFSETOF(type, member) __builtin_offsetof(type, member)
#define KJ_EXPECT_TRUE(condition) __builtin_expect(condition, true) #define KJ_EXPECT_TRUE(condition) __builtin_expect(condition, true)
#define KJ_EXPECT_FALSE(condition) __builtin_expect(condition, false) #define KJ_EXPECT_FALSE(condition) __builtin_expect(condition, false)
...@@ -80,7 +92,7 @@ typedef unsigned char byte; ...@@ -80,7 +92,7 @@ typedef unsigned char byte;
// expect the condition to be true/false enough of the time that it's worth hard-coding branch // expect the condition to be true/false enough of the time that it's worth hard-coding branch
// prediction. // prediction.
#ifdef NDEBUG #if defined(NDEBUG) && !__NO_INLINE__
#define KJ_ALWAYS_INLINE(prototype) inline prototype __attribute__((always_inline)) #define KJ_ALWAYS_INLINE(prototype) inline prototype __attribute__((always_inline))
// Force a function to always be inlined. Apply only to the prototype, not to the definition. // Force a function to always be inlined. Apply only to the prototype, not to the definition.
#else #else
......
...@@ -144,7 +144,7 @@ ExceptionCallback::~ExceptionCallback() { ...@@ -144,7 +144,7 @@ ExceptionCallback::~ExceptionCallback() {
} }
void ExceptionCallback::onRecoverableException(Exception&& exception) { void ExceptionCallback::onRecoverableException(Exception&& exception) {
#if __GNUC__ && !__EXCEPTIONS #if KJ_NO_EXCEPTIONS
logMessage(str(exception.what(), '\n')); logMessage(str(exception.what(), '\n'));
#else #else
if (std::uncaught_exception()) { if (std::uncaught_exception()) {
...@@ -156,7 +156,7 @@ void ExceptionCallback::onRecoverableException(Exception&& exception) { ...@@ -156,7 +156,7 @@ void ExceptionCallback::onRecoverableException(Exception&& exception) {
} }
void ExceptionCallback::onFatalException(Exception&& exception) { void ExceptionCallback::onFatalException(Exception&& exception) {
#if __GNUC__ && !__EXCEPTIONS #if KJ_NO_EXCEPTIONS
logMessage(str(exception.what(), '\n')); logMessage(str(exception.what(), '\n'));
#else #else
throw std::move(exception); throw std::move(exception);
......
...@@ -183,10 +183,6 @@ struct Stringifier { ...@@ -183,10 +183,6 @@ struct Stringifier {
return result; return result;
} }
// inline ArrayPtr<const char> operator*(Text::Reader text) const {
// return arrayPtr(text.data(), text.size());
// }
CappedArray<char, sizeof(short) * 4> operator*(short i) const; CappedArray<char, sizeof(short) * 4> operator*(short i) const;
CappedArray<char, sizeof(unsigned short) * 4> operator*(unsigned short i) const; CappedArray<char, sizeof(unsigned short) * 4> operator*(unsigned short i) const;
CappedArray<char, sizeof(int) * 4> operator*(int i) const; CappedArray<char, sizeof(int) * 4> operator*(int i) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment