diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f7642f4b..bbdeb27a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,27 +115,6 @@ endif() include_directories("${PROJECT_BINARY_DIR}") -include(CheckCSourceCompiles) - -# Check for different inline keyword versions. -foreach(KEYWORD "inline" "__inline__" "__inline") - set(CMAKE_REQUIRED_DEFINITIONS "-DKEYWORD=${KEYWORD}") - CHECK_C_SOURCE_COMPILES( - " - #include - KEYWORD void a() {} - int main(int argc, char **argv) { a(); return 0; } - " HAVE_${KEYWORD}) -endforeach() - -if (NOT HAVE_inline) - if (HAVE___inline__) - set(inline __inline__) - elseif(HAVE___inline) - set(inline __inline) - endif() -endif() - # Put the libaries and binaries that get built into directories at the # top of the build tree rather than in hard-to-find leaf directories. SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") diff --git a/config.h.cmake b/config.h.cmake index 0c2dbfba3..4a7bb4d9f 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -154,6 +154,3 @@ /* Define as `fork' if `vfork' does not work. */ //#cmakedefine vfork - -/* Define if the inline keyword doesn't exist. */ -#cmakedefine inline diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index a280f8aae..b47517bd3 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -144,7 +144,7 @@ static unsigned long long time_in_microseconds() } #ifdef _WIN32_WCE -static inline time_t time(time_t *t) +static LWS_INLINE time_t time(time_t *t) { time_t ret = time_in_microseconds() / 1000000; *t = ret; diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index a7c07aaa0..aff0e2aab 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -86,10 +86,18 @@ typedef SSIZE_T ssize_t; #include +#if !defined(__cplusplus) && defined(_MSC_VER) +#define LWS_INLINE __inline +#endif + #ifndef LWS_EXTERN #define LWS_EXTERN extern #endif +#ifndef LWS_INLINE +#define LWS_INLINE inline +#endif + #define CONTEXT_PORT_NO_LISTEN 0 #define MAX_MUX_RECURSION 2 @@ -1034,7 +1042,7 @@ libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, size_t len, enum libwebsocket_write_protocol protocol); /* helper for case where buffer may be const */ -static inline int +static LWS_INLINE int libwebsocket_write_http(struct libwebsocket *wsi, const unsigned char *buf, size_t len) { diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h index 4c340a1c6..6e68d5fd5 100644 --- a/lib/private-libwebsockets.h +++ b/lib/private-libwebsockets.h @@ -461,10 +461,10 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *context, struct libwebsocket *wsi, enum lws_close_status); #ifndef LWS_LATENCY -static inline void lws_latency(struct libwebsocket_context *context, +static LWS_INLINE void lws_latency(struct libwebsocket_context *context, struct libwebsocket *wsi, const char *action, int ret, int completion) { while (0); } -static inline void lws_latency_pre(struct libwebsocket_context *context, +static LWS_INLINE void lws_latency_pre(struct libwebsocket_context *context, struct libwebsocket *wsi) { while (0); } #else #define lws_latency_pre(_context, _wsi) lws_latency(_context, _wsi, NULL, 0, 0) diff --git a/lib/server.c b/lib/server.c index 2f2c5b382..2ec280b57 100644 --- a/lib/server.c +++ b/lib/server.c @@ -485,7 +485,7 @@ LWS_VISIBLE int libwebsockets_return_http_status( } #if defined(WIN32) || defined(_WIN32) -static inline HANDLE lws_open_file(const char* filename, unsigned long* filelen) +static LWS_INLINE HANDLE lws_open_file(const char* filename, unsigned long* filelen) { HANDLE ret; WCHAR buffer[MAX_PATH]; @@ -501,7 +501,7 @@ static inline HANDLE lws_open_file(const char* filename, unsigned long* filelen) return ret; } #else -static inline int lws_open_file(const char* filename, unsigned long* filelen) +static LWS_INLINE int lws_open_file(const char* filename, unsigned long* filelen) { struct stat stat_buf; int ret = open(filename, O_RDONLY);