Make code friendly to WebAssembly. (#140)

This does not add any build stuff or new sample code yet, it just does
some prep to our C++ codebase:

- Similar to Android, WebAssembly will not be using BlueGL. We were
  using a mixture of #if and #ifdef when checking for the existence of
  certain GL prototypes, but the latter is what we want in order to
  build robustly with any GL headers. (We still perform run-time checks
  for extensions, this doesn't change that.)

- Add a trivial ContextManager, does a bit more than Dummy since it
  needs to create an actual driver. This doesn't get compiled yet, it
  just adds files to the tree.

- WebAssembly does not support mmap, execinfo, or asm volatile.
This commit is contained in:
Philip Rideout
2018-08-24 17:17:40 -07:00
committed by GitHub
parent a0d1084b40
commit 446959042f
8 changed files with 144 additions and 15 deletions

View File

@@ -22,9 +22,12 @@
#include <algorithm>
#include <memory>
// FIXME: Android doesn't have execinfo.h (but has unwind.h)
#if !defined(ANDROID) && !defined(WIN32)
// FIXME: Some platforms do not have execinfo.h (but have unwind.h)
#if !defined(ANDROID) && !defined(WIN32) && !defined(__EMSCRIPTEN__)
#include <execinfo.h>
#define HAS_EXECINFO 1
#else
#define HAS_EXECINFO 0
#endif
#if !defined(WIN32)
@@ -76,7 +79,7 @@ void CallStack::update_gcc(size_t ignore) noexcept {
ssize_t size = 0;
void *array[NUM_FRAMES];
#if !defined(ANDROID) && !defined(WIN32)
#if HAS_EXECINFO
size = ::backtrace(array, NUM_FRAMES);
size -= ignore;
#endif
@@ -115,7 +118,7 @@ utils::CString CallStack::demangleTypeName(const char* mangled) {
// ------------------------------------------------------------------------------------------------
io::ostream& operator<<(io::ostream& stream, const CallStack& callstack) {
#if !defined(ANDROID) && !defined(WIN32)
#if HAS_EXECINFO
size_t size = callstack.getFrameCount();
for (size_t i = 0; i < size; i++) {
intptr_t pc = callstack[i];