From: Alexander Lukichev Date: Tue, 20 Oct 2015 10:10:33 +0000 (+0300) Subject: Make LWS_SEND_BUFFER_PRE_PADDING preprocessor if-friendly X-Git-Tag: upstream/1.7.3~326 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fe6030a62bf0ba643781c750b05259b7b246b266;p=platform%2Fupstream%2Flibwebsockets.git Make LWS_SEND_BUFFER_PRE_PADDING preprocessor if-friendly Commit 173e9c4e made LWS_SEND_BUFFER_SIZE a multiple of a certain value returned by _LWS_PAD_SIZE macro. This macro expanded to "sizeof(void *)" on non-x86_64 architectures, which made it unsuitable to use LWS_SEND_BUFFER_SIZE in preprocessor #if expressions in the library user code. This patch preserves the padding logic since commit 173e9c4e but makes it more preprocessor-friendly for applications using libwebsockets by setting _LWS_PAD_SIZE to the size of "void *" determined by cmake when libwebsockets is configured for the target platform. Signed-off-by: Alexander Lukichev --- diff --git a/CMakeLists.txt b/CMakeLists.txt index e77e3c7..88ac3d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -300,6 +300,7 @@ CHECK_INCLUDE_FILES("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS) CHECK_TYPE_SIZE(pid_t PID_T_SIZE) CHECK_TYPE_SIZE(size_t SIZE_T_SIZE) +CHECK_TYPE_SIZE("void *" LWS_SIZEOFPTR LANGUAGE C) if (NOT PID_T_SIZE) set(pid_t int) diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index 7ab6dca..4376f48 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -1231,7 +1231,7 @@ libwebsocket_set_timeout(struct libwebsocket *wsi, #if __x86_64__ #define _LWS_PAD_SIZE 16 // Intel recommended for best performance. #else -#define _LWS_PAD_SIZE sizeof(void *) // The pointer size on any unknown arch. +#define _LWS_PAD_SIZE LWS_SIZEOFPTR /* Size of a pointer on the target architecture */ #endif #define _LWS_PAD(n) (((n) % _LWS_PAD_SIZE) ? ((n) + (_LWS_PAD_SIZE - ((n) % _LWS_PAD_SIZE))) : (n)) #define LWS_SEND_BUFFER_PRE_PADDING _LWS_PAD(4 + 10 + (2 * MAX_MUX_RECURSION)) diff --git a/lws_config.h.in b/lws_config.h.in index f4b0ac4..4c3c3b9 100644 --- a/lws_config.h.in +++ b/lws_config.h.in @@ -61,3 +61,5 @@ /* use SHA1() not internal libwebsockets_SHA1 */ #cmakedefine LWS_SHA1_USE_OPENSSL_NAME + +${LWS_SIZEOFPTR_CODE}