Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the build on OpenBSD #1333

Merged
merged 2 commits into from Apr 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions cmake/platformChecks.cmake
Expand Up @@ -7,17 +7,27 @@ include(CheckLibraryExists)
include(CheckPrototypeDefinition)
include(CheckStructHasMember)
include(CheckSymbolExists)
include(CheckCXXSymbolExists)
include(CheckTypeSize)

CHECK_INCLUDE_FILE("execinfo.h" HAVE_EXECINFO_H)
CHECK_INCLUDE_FILE_CXX("cxxabi.h" HAVE_CXXAPI_H)

CHECK_TYPE_SIZE("max_align_t" MAX_ALIGN_T)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_REQUIRED_FLAGS "-std=c++11") # required for g++ <= 5
endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")

set(CMAKE_EXTRA_INCLUDE_FILES "cstddef")
CHECK_TYPE_SIZE("std::max_align_t" STD_MAX_ALIGN_T LANGUAGE CXX)
set(CMAKE_EXTRA_INCLUDE_FILES "type_traits")
CHECK_TYPE_SIZE("std::is_trivially_copyable<int>" STD_IS_TRIVIALLY_COPYABLE LANGUAGE CXX)
set(CMAKE_EXTRA_INCLUDE_FILES)

set(CMAKE_REQUIRED_FLAGS)


CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)

Expand Down
2 changes: 2 additions & 0 deletions cmake/platformChecks.h.in
Expand Up @@ -8,6 +8,8 @@
#cmakedefine HAVE_MAX_ALIGN_T
#cmakedefine HAVE_STD_MAX_ALIGN_T

#cmakedefine HAVE_STD_IS_TRIVIALLY_COPYABLE

#cmakedefine01 IS_64BIT

#cmakedefine01 HAVE_STRCASECMP
Expand Down
4 changes: 3 additions & 1 deletion code/scripting/ade.h
Expand Up @@ -5,6 +5,7 @@
#define FS2_OPEN_ADE_H

#include "globalincs/pstypes.h"
#include "platformChecks.h"

extern "C" {
#include <lauxlib.h>
Expand Down Expand Up @@ -226,8 +227,9 @@ template<class StoreType>
class ade_obj: public ade_lib_handle {
public:
// Make sure that the stored type is compatible with our requirements
#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE
static_assert(std::is_trivially_copyable<StoreType>::value, "ADE object types must be trivially copyable!");

#endif
ade_obj(const char* in_name, const char* in_desc, const ade_lib_handle* in_deriv = NULL) {
ade_table_entry ate;

Expand Down
18 changes: 9 additions & 9 deletions code/scripting/lua/LuaTable.cpp
Expand Up @@ -97,39 +97,39 @@ LuaTable::iterator LuaTable::end() {
return iterator(); // Empty iterator
}

LuaTableIterator::LuaTableIterator(const LuaTable& t) : _L(t.getLuaState()) {
_stackTop = lua_gettop(_L);
LuaTableIterator::LuaTableIterator(const LuaTable& t) : _luaState(t.getLuaState()) {
_stackTop = lua_gettop(_luaState);

t.pushValue();
lua_pushnil(_L);
lua_pushnil(_luaState);

toNextElement();
}
LuaTableIterator::~LuaTableIterator() {
lua_settop(_L, _stackTop);
lua_settop(_luaState, _stackTop);
}
bool LuaTableIterator::hasElement() {
return _hasElement;
}
void LuaTableIterator::toNextElement() {
auto ret = lua_next(_L, -2);
auto ret = lua_next(_luaState, -2);

_hasElement = ret != 0;

if (_hasElement) {
LuaValue key;
key.setReference(UniqueLuaReference::create(_L, -2));
key.setReference(UniqueLuaReference::create(_luaState, -2));

LuaValue value;
value.setReference(UniqueLuaReference::create(_L, -1));
value.setReference(UniqueLuaReference::create(_luaState, -1));

_currentVal = std::make_pair(key, value);

// Remove value from stack
lua_pop(_L, 1);
lua_pop(_luaState, 1);
}
}
std::pair<LuaValue, LuaValue> LuaTableIterator::getElement() {
return _currentVal;
}
}
}
2 changes: 1 addition & 1 deletion code/scripting/lua/LuaTable.h
Expand Up @@ -19,7 +19,7 @@ class LuaTable;
* be in the exact same state when you call the next method of this class.
*/
class LuaTableIterator {
lua_State* _L = nullptr;
lua_State* _luaState = nullptr;

int _stackTop = 0;

Expand Down