|
2 | 2 | #include <cassert> |
3 | 3 | #include <set> |
4 | 4 | #include "cxxopts.hpp" |
5 | | -#include "roaring.hh" |
6 | 5 | #include "osmium/handler.hpp" |
7 | 6 | #include "osmium/io/any_input.hpp" |
8 | 7 | #include "osmium/visitor.hpp" |
9 | 8 | #include "osmium/util/progress_bar.hpp" |
| 9 | +#include "roaring/roaring.hh" |
| 10 | + |
| 11 | +// Historically, OSMExpress had vendored its dependencies, but we move away |
| 12 | +// from this. At the moment, the S2 geometry library is the last remaining |
| 13 | +// dependency still being vendored. Our (rather ancient) bundled version |
| 14 | +// of S2 tests for a number of implementations of the Standard C library. |
| 15 | +// If S2 happens to recognize the library, it includes <byteswap.h> |
| 16 | +// (unless it is being compiled by a Microsoft or Apple compiler); |
| 17 | +// otherwise, S2 falls back to its own byteswap implementation. |
| 18 | +// What S2 does (or rather did, in the old version we happen |
| 19 | +// to bundle) isn't so great; it would have been better for S2 to use |
| 20 | +// a standards-conforming way of byteswapping, test for its presence, |
| 21 | +// and only use the fallback if that test fails. But that's how it is. |
| 22 | +// |
| 23 | +// Anyhow, the (equally ancient) version of CRoaring, another library |
| 24 | +// that we previously vendored into OSMExpress, was polluting the |
| 25 | +// C macro namespace in a way that made our bundled version of S2 |
| 26 | +// believe to be on a C library it knew about. Therefore, at the time |
| 27 | +// when OSMExpress still vendored that old version of CRoaring, the |
| 28 | +// bundled version of S2 would always include <byteswap.h> instead |
| 29 | +// of (re-)defining it, even if S2 did not recognize the C library. |
| 30 | +// |
| 31 | +// As we upgraded CRoaring to a newer version, which does not pollute |
| 32 | +// the C macro namespace anymore, the C preprocessor would now execute |
| 33 | +// the fallback path in the S2 headers when compiling with a Standard C |
| 34 | +// library that our old version of S2 does not recognize. This caused |
| 35 | +// compilation errors on Alpine Linux, which uses musl, a very lightweight |
| 36 | +// but fully standards-conforming implementation of the Standard C library. |
| 37 | +// |
| 38 | +// The following hack prevents our vendored old version of S2 from |
| 39 | +// supplying its own byteswap functions. On Bionic (and also other |
| 40 | +// modern libc implementations, including musl), it is sufficient to |
| 41 | +// include <byteswap.h>. Note we cannot explicitly test for musl here, |
| 42 | +// because musl does not define a __MUSL__ macro. (They don't want to, |
| 43 | +// since such a macro would not be standards-conforming; whether it's |
| 44 | +// really helpful to be so puristic has been the subject of much debate). |
| 45 | +// |
| 46 | +// TODO: Remove this hack once we stop vendoring the S2 geometry library. |
| 47 | +// https://github.com/bdon/OSMExpress/issues/20 |
| 48 | +#if !defined(_MSC_VER) && !defined(__APPLE__) && !defined(__GLIBC__) \ |
| 49 | + && !defined(__BIONIC__) && !defined(__ASYLO__) |
| 50 | +#define __BIONIC__ 1 |
| 51 | +#endif |
| 52 | + |
10 | 53 | #include "s2/s2latlng.h" |
11 | 54 | #include "s2/s2cell_union.h" |
| 55 | + |
12 | 56 | #include "osmx/storage.h" |
13 | 57 | #include "osmx/util.h" |
14 | 58 |
|
|
0 commit comments