1
0
mirror of https://github.com/lammertb/libhttp.git synced 2025-12-22 04:02:04 +03:00

Support build for Lua 5.1 (for LuaJIT), Lua 5.2 and Lua 5.3 (Step 2/?)

See #195
This commit is contained in:
bel
2015-08-22 21:43:38 +02:00
parent 2c614b584c
commit b06ded3056
6 changed files with 68 additions and 38 deletions

View File

@@ -119,7 +119,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>USE_IPV6;LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;USE_LUA_FILE_SYSTEM;USE_WEBSOCKET;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party\lua-5.2.4\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party;$(ProjectDir)..\..\src\third_party\lua-5.2.4\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -133,7 +133,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>USE_IPV6;LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;USE_LUA_FILE_SYSTEM;USE_WEBSOCKET;WIN32;CONSOLE;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party\lua-5.2.4\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party;$(ProjectDir)..\..\src\third_party\lua-5.2.4\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@@ -177,7 +177,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>USE_IPV6;LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;USE_LUA_FILE_SYSTEM;USE_WEBSOCKET;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party\lua-5.2.4\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party;$(ProjectDir)..\..\src\third_party\lua-5.2.4\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -209,6 +209,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\civetweb.h" />
<ClInclude Include="..\..\src\third_party\civetweb_lua.h" />
<ClInclude Include="..\..\src\third_party\lua-5.2.4\src\lauxlib.h" />
<ClInclude Include="..\..\src\third_party\lua-5.2.4\src\lua.h" />
</ItemGroup>

View File

@@ -30,6 +30,9 @@
<ClInclude Include="..\..\src\third_party\lua-5.2.4\src\lauxlib.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\third_party\civetweb_lua.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\civetweb.c">
@@ -60,4 +63,4 @@
<Filter>inl files</Filter>
</None>
</ItemGroup>
</Project>
</Project>

View File

@@ -1,29 +1,7 @@
#include <lua.h>
#include <lauxlib.h>
#include "civetweb_lua.h"
#include "lua_civet.h"
#ifndef LUA_VERSION_NUM
#error "Unknown Lua version"
#elif LUA_VERSION_NUM == 501
/* Lua 5.1 detected */
#define LUA_OK 0
#define LUA_ERRGCMM 999 /* not supported */
#define mg_lua_load(a,b,c,d,e) lua_load(a,b,c,d)
#define lua_rawlen lua_objlen
#define lua_newstate(a, b) luaL_newstate() /* Must use luaL_newstate() for 64 bit target */
#elif LUA_VERSION_NUM == 502
/* Lua 5.2 detected */
#define mg_lua_load lua_load
#elif LUA_VERSION_NUM == 503
/* Lua 5.3 detected */
#define mg_lua_load lua_load
#endif
#ifdef _WIN32
static void *
mmap(void *addr, int64_t len, int prot, int flags, int fd, int offset)

56
src/third_party/civetweb_lua.h vendored Normal file
View File

@@ -0,0 +1,56 @@
/* Copyright (c) 2015 the Civetweb developers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/* This header is intended to support Lua 5.1, Lua 5.2 and Lua 5.3 in the same
* C source code.
*/
#ifndef CIVETWEB_LUA_H
#define CIVETWEB_LUA_H
#define LUA_LIB
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#ifndef LUA_VERSION_NUM
#error "Unknown Lua version"
#elif LUA_VERSION_NUM == 501
/* Lua 5.1 detected */
#define LUA_OK 0
#define LUA_ERRGCMM 999 /* not supported */
#define mg_lua_load(a,b,c,d,e) lua_load(a,b,c,d)
#define lua_rawlen lua_objlen
#define lua_newstate(a, b) luaL_newstate() /* Must use luaL_newstate() for 64 bit target */
#define lua_pushinteger lua_pushnumber
#elif LUA_VERSION_NUM == 502
/* Lua 5.2 detected */
#define mg_lua_load lua_load
#elif LUA_VERSION_NUM == 503
/* Lua 5.3 detected */
#define mg_lua_load lua_load
#endif
#endif /* #ifndef CIVETWEB_LUA_H */

View File

@@ -64,9 +64,7 @@
#include <utime.h>
#endif
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include "civetweb_lua.h"
#include "lfs.h"

View File

@@ -30,13 +30,7 @@
#include <string.h>
#include <assert.h>
#define LUA_LIB
#include "lua.h"
#include "lauxlib.h"
#if LUA_VERSION_NUM == 501
#define lua_pushinteger lua_pushnumber
#endif
#include "civetweb_lua.h"
#if LUA_VERSION_NUM > 501
/*