Commit b17b5ae8 authored by Kenton Varda's avatar Kenton Varda

Merge pull request #147 from teobugslayer/msvc

Accommodate code for MSVC
parents 1745aded c1d3386d
...@@ -191,7 +191,7 @@ public: ...@@ -191,7 +191,7 @@ public:
return Promise<T>(false, neverDone()); return Promise<T>(false, neverDone());
} }
void wait(WaitScope& waitScope) const KJ_NORETURN; KJ_NORETURN(void wait(WaitScope& waitScope) const);
}; };
} // namespace _ (private) } // namespace _ (private)
......
...@@ -126,11 +126,20 @@ typedef unsigned char byte; ...@@ -126,11 +126,20 @@ typedef unsigned char byte;
#define KJ_ALWAYS_INLINE(prototype) inline prototype #define KJ_ALWAYS_INLINE(prototype) inline prototype
// Don't force inline in debug mode. // Don't force inline in debug mode.
#else #else
#if defined(_MSC_VER)
#define KJ_ALWAYS_INLINE(prototype) __forceinline prototype
#else
#define KJ_ALWAYS_INLINE(prototype) inline prototype __attribute__((always_inline)) #define KJ_ALWAYS_INLINE(prototype) inline prototype __attribute__((always_inline))
#endif
// 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.
#endif #endif
#define KJ_NORETURN __attribute__((noreturn)) #if defined(_MSC_VER)
#define KJ_NORETURN(prototype) __declspec(noreturn) prototype
#else
#define KJ_NORETURN(prototype) prototype __attribute__((noreturn))
#endif
#define KJ_UNUSED __attribute__((unused)) #define KJ_UNUSED __attribute__((unused))
#define KJ_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) #define KJ_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
...@@ -153,14 +162,14 @@ typedef unsigned char byte; ...@@ -153,14 +162,14 @@ typedef unsigned char byte;
namespace _ { // private namespace _ { // private
void inlineRequireFailure( KJ_NORETURN(void inlineRequireFailure(
const char* file, int line, const char* expectation, const char* macroArgs, const char* file, int line, const char* expectation, const char* macroArgs,
const char* message = nullptr) KJ_NORETURN; const char* message = nullptr));
void inlineAssertFailure( KJ_NORETURN(void inlineAssertFailure(
const char* file, int line, const char* expectation, const char* macroArgs, const char* file, int line, const char* expectation, const char* macroArgs,
const char* message = nullptr) KJ_NORETURN; const char* message = nullptr));
void unreachable() KJ_NORETURN; KJ_NORETURN(void unreachable());
} // namespace _ (private) } // namespace _ (private)
......
...@@ -223,7 +223,7 @@ public: ...@@ -223,7 +223,7 @@ public:
const char* condition, const char* macroArgs, Params&&... params); const char* condition, const char* macroArgs, Params&&... params);
~Fault() noexcept(false); ~Fault() noexcept(false);
void fatal() KJ_NORETURN; KJ_NORETURN(void fatal());
// Throw the exception. // Throw the exception.
private: private:
......
...@@ -184,7 +184,7 @@ private: ...@@ -184,7 +184,7 @@ private:
ExceptionCallback& getExceptionCallback(); ExceptionCallback& getExceptionCallback();
// Returns the current exception callback. // Returns the current exception callback.
void throwFatalException(kj::Exception&& exception) KJ_NORETURN; KJ_NORETURN(void throwFatalException(kj::Exception&& exception));
// Invoke the exception callback to throw the given fatal exception. If the exception callback // Invoke the exception callback to throw the given fatal exception. If the exception callback
// returns, abort. // returns, abort.
......
...@@ -382,8 +382,8 @@ public: ...@@ -382,8 +382,8 @@ public:
private: private:
Own<Impl> impl; Own<Impl> impl;
void usageError(StringPtr programName, StringPtr message) KJ_NORETURN; KJ_NORETURN(void usageError(StringPtr programName, StringPtr message));
void printHelp(StringPtr programName) KJ_NORETURN; KJ_NORETURN(void printHelp(StringPtr programName));
void wrapText(Vector<char>& output, StringPtr indent, StringPtr text); void wrapText(Vector<char>& output, StringPtr indent, StringPtr text);
}; };
......
...@@ -36,7 +36,7 @@ public: ...@@ -36,7 +36,7 @@ public:
virtual StringPtr getProgramName() = 0; virtual StringPtr getProgramName() = 0;
// Get argv[0] as passed to main(). // Get argv[0] as passed to main().
virtual void exit() KJ_NORETURN = 0; KJ_NORETURN(virtual void exit()) = 0;
// Indicates program completion. The program is considered successful unless `error()` was // Indicates program completion. The program is considered successful unless `error()` was
// called. Typically this exits with _Exit(), meaning that the stack is not unwound, buffers // called. Typically this exits with _Exit(), meaning that the stack is not unwound, buffers
// are not flushed, etc. -- it is the responsibility of the caller to flush any buffers that // are not flushed, etc. -- it is the responsibility of the caller to flush any buffers that
...@@ -110,10 +110,10 @@ public: ...@@ -110,10 +110,10 @@ public:
// Like `warning()`, but also sets a flag indicating that the process has failed, and that when // Like `warning()`, but also sets a flag indicating that the process has failed, and that when
// it eventually exits it should indicate an error status. // it eventually exits it should indicate an error status.
virtual void exitError(StringPtr message) KJ_NORETURN = 0; KJ_NORETURN(virtual void exitError(StringPtr message)) = 0;
// Equivalent to `error(message)` followed by `exit()`. // Equivalent to `error(message)` followed by `exit()`.
virtual void exitInfo(StringPtr message) KJ_NORETURN = 0; KJ_NORETURN(virtual void exitInfo(StringPtr message)) = 0;
// Displays the given non-error message to the user and then calls `exit()`. This is used to // Displays the given non-error message to the user and then calls `exit()`. This is used to
// implement things like --help. // implement things like --help.
...@@ -141,11 +141,11 @@ public: ...@@ -141,11 +141,11 @@ public:
// are easily confused by quick_exit(). // are easily confused by quick_exit().
StringPtr getProgramName() override; StringPtr getProgramName() override;
void exit() override KJ_NORETURN; KJ_NORETURN(void exit() override);
void warning(StringPtr message) override; void warning(StringPtr message) override;
void error(StringPtr message) override; void error(StringPtr message) override;
void exitError(StringPtr message) override KJ_NORETURN; KJ_NORETURN(void exitError(StringPtr message) override);
void exitInfo(StringPtr message) override KJ_NORETURN; KJ_NORETURN(void exitInfo(StringPtr message) override);
void increaseLoggingVerbosity() override; void increaseLoggingVerbosity() override;
private: private:
......
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