Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/libutil/strutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#if defined(__APPLE__) || defined(__FreeBSD__)
# include <xlocale.h>
#endif
#ifdef __EMSCRIPTEN__
# include <strings.h>
#endif
#ifdef _WIN32
# include <windows.h>
#endif
Expand All @@ -45,7 +48,7 @@
#endif
#define stbsp__uintptr std::uintptr_t

#ifdef OpenImageIO_SANITIZE
#if defined(OpenImageIO_SANITIZE) || defined(__EMSCRIPTEN__)
# define STB_SPRINTF_NOUNALIGNED
#endif

Expand Down Expand Up @@ -533,6 +536,8 @@ strcasecmp(const char* a, const char* b)
if (*us1++ == '\0')
return (0);
return (tolower_l(*us1, c_loc) - tolower_l(*--us2, c_loc));
#elif defined(__EMSCRIPTEN__)
return ::strcasecmp(a, b);
#else
# error("need equivalent of strcasecmp_l on this platform");
#endif
Expand Down Expand Up @@ -561,6 +566,8 @@ strncasecmp(const char* a, const char* b, size_t size)
} while (--size != 0);
}
return (0);
#elif defined(__EMSCRIPTEN__)
return ::strncasecmp(a, b, size);
#else
# error("need equivalent of strncasecmp_l on this platform");
#endif
Expand Down
14 changes: 13 additions & 1 deletion src/libutil/sysutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
# include <unistd.h>
#endif

#ifdef __EMSCRIPTEN__
# include <chrono>
# include <unistd.h>
#endif

#include <OpenImageIO/dassert.h>
#include <OpenImageIO/filesystem.h>
#include <OpenImageIO/strutil.h>
Expand Down Expand Up @@ -130,6 +135,8 @@ Sysutil::memory_used(bool resident)
// FIXME -- does somebody know a good method for figuring this out for
// FreeBSD?
return 0; // Punt
#elif defined(__EMSCRIPTEN__)
return 0;
#else
// No idea what platform this is
OIIO_ASSERT(0 && "Need to implement Sysutil::memory_used on this platform");
Expand Down Expand Up @@ -202,6 +209,8 @@ Sysutil::physical_memory()
sysctl(mib, 2, &physical_memory, &length, NULL, 0);
return physical_memory;

#elif defined(__EMSCRIPTEN__)
return 0;
#else
// No idea what platform this is
OIIO_ASSERT(
Expand Down Expand Up @@ -268,7 +277,8 @@ Sysutil::this_program_path()
size_t cb = sizeof(filename);
int r = 1;
sysctl(mib, 4, filename, &cb, NULL, 0);
#elif defined(__GNU__) || defined(__OpenBSD__) || defined(_WIN32)
#elif defined(__GNU__) || defined(__OpenBSD__) || defined(_WIN32) \
|| defined(__EMSCRIPTEN__)
int r = 0;
#else
// No idea what platform this is
Expand Down Expand Up @@ -299,6 +309,8 @@ Sysutil::usleep(unsigned long useconds)
{
#ifdef _WIN32
Sleep(useconds / 1000); // Win32 Sleep() is milliseconds, not micro
#elif defined(__EMSCRIPTEN__)
std::this_thread::sleep_for(std::chrono::microseconds(useconds));
#else
::usleep(useconds); // *nix usleep() is in microseconds
#endif
Expand Down
Loading