Skip to content

Commit 7b7c14b

Browse files
committed
Merge branch 'master' of github.com:systemed/tilemaker
2 parents 3c4fdb8 + 653ffb8 commit 7b7c14b

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ add_executable(tilemaker vector_tile.pb.cc osmformat.pb.cc ${tilemaker_src_files
110110
target_link_libraries(tilemaker ${PROTOBUF_LIBRARY} ${LIBSHP_LIBRARIES} ${SQLITE3_LIBRARIES} ${LUAJIT_LIBRARY} ${LUA_LIBRARIES} ${ZLIB_LIBRARY} ${THREAD_LIB} ${CMAKE_DL_LIBS}
111111
Boost::system Boost::filesystem Boost::program_options Boost::iostreams)
112112

113+
include(CheckCxxAtomic)
114+
if(NOT HAVE_CXX11_ATOMIC)
115+
string(APPEND CMAKE_CXX_STANDARD_LIBRARIES
116+
" ${LIBATOMIC_LINK_FLAGS}")
117+
endif()
118+
113119
if(MSVC)
114120
target_link_libraries(tilemaker unofficial::sqlite3::sqlite3)
115121
endif()

cmake/CheckCxxAtomic.cmake

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# some platforms do not offer support for atomic primitive for all integer
2+
# types, in that case we need to link against libatomic
3+
4+
include(CheckCXXSourceCompiles)
5+
include(CMakePushCheckState)
6+
7+
8+
function(check_cxx_atomics var)
9+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11")
10+
check_cxx_source_compiles("
11+
#include <atomic>
12+
#include <cstdint>
13+
#include <cstddef>
14+
#if defined(__SIZEOF_INT128__)
15+
// Boost needs 16-byte atomics for tagged pointers.
16+
// These are implemented via inline instructions on the platform
17+
// if 16-byte alignment can be proven, and are delegated to libatomic
18+
// library routines otherwise. Whether or not alignment is provably
19+
// OK for a std::atomic unfortunately depends on compiler version and
20+
// optimization levels, and also on the details of the expression.
21+
// We specifically test access via an otherwise unknown pointer here
22+
// to ensure we get the most complex case. If this access can be
23+
// done without libatomic, then all accesses can be done.
24+
struct tagged_ptr {
25+
int* ptr;
26+
std::size_t tag;
27+
};
28+
void atomic16(std::atomic<tagged_ptr> *ptr)
29+
{
30+
tagged_ptr p{nullptr, 1};
31+
ptr->store(p);
32+
tagged_ptr f = ptr->load();
33+
tagged_ptr new_tag{nullptr, 0};
34+
ptr->compare_exchange_strong(f, new_tag);
35+
}
36+
#endif
37+
int main() {
38+
#if defined(__SIZEOF_INT128__)
39+
std::atomic<tagged_ptr> ptr;
40+
atomic16(&ptr);
41+
#endif
42+
std::atomic<uint8_t> w1;
43+
std::atomic<uint16_t> w2;
44+
std::atomic<uint32_t> w4;
45+
std::atomic<uint64_t> w8;
46+
return w1 + w2 + w4 + w8;
47+
}
48+
" ${var})
49+
endfunction(check_cxx_atomics)
50+
51+
cmake_push_check_state()
52+
check_cxx_atomics(HAVE_CXX11_ATOMIC)
53+
cmake_pop_check_state()
54+
55+
if(NOT HAVE_CXX11_ATOMIC)
56+
cmake_push_check_state()
57+
set(CMAKE_REQUIRED_LIBRARIES "atomic")
58+
check_cxx_atomics(HAVE_LIBATOMIC)
59+
cmake_pop_check_state()
60+
if(HAVE_LIBATOMIC)
61+
set(LIBATOMIC_LINK_FLAGS "-latomic")
62+
else()
63+
message(FATAL_ERROR
64+
"Host compiler ${CMAKE_CXX_COMPILER} requires libatomic, but it is not found")
65+
endif()
66+
endif()

src/osm_lua_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ void OsmLuaProcessing::LayerAsCentroid(const string &layerName) {
415415
cout << "Couldn't find " << (isRelation ? "relation " : isWay ? "way " : "node " ) << originalOsmID << ": " << err.what() << endl;
416416
return;
417417
} catch (geom::centroid_exception &err) {
418-
cerr << "Problem geometry " << (isRelation ? "relation " : isWay ? "way " : "node " ) << originalOsmID << ": " << err.what() << endl;
418+
if (verbose) cerr << "Problem geometry " << (isRelation ? "relation " : isWay ? "way " : "node " ) << originalOsmID << ": " << err.what() << endl;
419419
return;
420420
} catch (std::invalid_argument &err) {
421421
cerr << "Error in OutputObjectOsmStore constructor for " << (isRelation ? "relation " : isWay ? "way " : "node " ) << originalOsmID << ": " << err.what() << endl;

0 commit comments

Comments
 (0)