diff options
author | dtorilov <dtorilov@yandex-team.com> | 2024-03-28 21:07:32 +0300 |
---|---|---|
committer | dtorilov <dtorilov@yandex-team.com> | 2024-03-28 21:18:22 +0300 |
commit | 69da0d084c7045f516e59ff13afeb15a3f313b5d (patch) | |
tree | 03a0355dba12f54746d8f24133c1551d8fdaf5f4 | |
parent | 22f953d76634703f1ac2d06ec90fe270ceaafe74 (diff) | |
download | ydb-69da0d084c7045f516e59ff13afeb15a3f313b5d.tar.gz |
WebAssembly in util
b46c1e446c9d0f9393bf688b26db810f60add0f6
-rw-r--r-- | build/sysincl/emscripten.yml | 1 | ||||
-rw-r--r-- | util/datetime/uptime.cpp | 4 | ||||
-rw-r--r-- | util/datetime/ya.make | 8 | ||||
-rw-r--r-- | util/digest/ya.make | 12 | ||||
-rw-r--r-- | util/folder/fts.cpp | 4 | ||||
-rw-r--r-- | util/folder/ya.make | 2 | ||||
-rw-r--r-- | util/generic/ya.make | 2 | ||||
-rw-r--r-- | util/memory/ya.make | 2 | ||||
-rw-r--r-- | util/network/socket.cpp | 2 | ||||
-rw-r--r-- | util/stream/ya.make | 2 | ||||
-rw-r--r-- | util/string/ya.make | 2 | ||||
-rw-r--r-- | util/system/error.cpp | 2 | ||||
-rw-r--r-- | util/system/filemap.cpp | 2 | ||||
-rw-r--r-- | util/system/platform.h | 12 | ||||
-rw-r--r-- | util/system/types.h | 2 | ||||
-rw-r--r-- | util/system/ya.make | 2 | ||||
-rw-r--r-- | util/ut/ya.make | 2 | ||||
-rw-r--r-- | util/ya.make | 24 |
18 files changed, 59 insertions, 28 deletions
diff --git a/build/sysincl/emscripten.yml b/build/sysincl/emscripten.yml index 92f5684c2b..7ae4c55c9d 100644 --- a/build/sysincl/emscripten.yml +++ b/build/sysincl/emscripten.yml @@ -261,6 +261,7 @@ - sys/socket.h: contrib/restricted/emscripten/system/lib/libc/musl/include/sys/socket.h - sys/soundcard.h: contrib/restricted/emscripten/system/lib/libc/musl/include/sys/soundcard.h - sys/statfs.h: contrib/restricted/emscripten/system/lib/libc/musl/include/sys/statfs.h + - sys/socketvar.h: contrib/restricted/emscripten/system/include/compat/sys/socketvar.h - sys/stat.h: - contrib/restricted/emscripten/system/include/compat/sys/stat.h diff --git a/util/datetime/uptime.cpp b/util/datetime/uptime.cpp index 12476a94bf..d2e1191c84 100644 --- a/util/datetime/uptime.cpp +++ b/util/datetime/uptime.cpp @@ -52,5 +52,9 @@ TDuration Uptime() { return TDuration::MilliSeconds(up * 1000.0); #elif defined(_darwin_) return GetDarwinUptime(); +#elif defined(_emscripten_) + ythrow yexception() << "unimplemented"; +#else + #error "Implement this method" #endif } diff --git a/util/datetime/ya.make b/util/datetime/ya.make index f4a66598a0..1e23d869af 100644 --- a/util/datetime/ya.make +++ b/util/datetime/ya.make @@ -1,8 +1,10 @@ SUBSCRIBER(g:util-subscribers) -RECURSE( - benchmark -) +IF (NOT OS_EMSCRIPTEN) + RECURSE( + benchmark + ) +ENDIF() RECURSE_FOR_TESTS( ut diff --git a/util/digest/ya.make b/util/digest/ya.make index d1c47dc23b..736494e8ac 100644 --- a/util/digest/ya.make +++ b/util/digest/ya.make @@ -1,11 +1,13 @@ SUBSCRIBER(g:util-subscribers) -RECURSE( - benchmark - ut -) +IF (NOT OS_EMSCRIPTEN) + RECURSE( + benchmark + ut + ) +ENDIF() -IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT USE_SYSTEM_PYTHON) +IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT OS_EMSCRIPTEN AND NOT USE_SYSTEM_PYTHON) RECURSE( ut_cython ) diff --git a/util/folder/fts.cpp b/util/folder/fts.cpp index b2e75c8eca..609a56b076 100644 --- a/util/folder/fts.cpp +++ b/util/folder/fts.cpp @@ -174,7 +174,7 @@ dird get_dird(char* path) { static int fts_safe_changedir(FTS*, FTSENT*, int, dird); #endif -#if defined(__svr4__) || defined(__linux__) || defined(__CYGWIN__) || defined(_win_) +#if defined(__svr4__) || defined(__linux__) || defined(__CYGWIN__) || defined(_win_) || defined(_emscripten_) #ifdef MAX #undef MAX #endif @@ -183,7 +183,7 @@ static int fts_safe_changedir(FTS*, FTSENT*, int, dird); #undef ALIGN #define ALIGNBYTES (sizeof(long long) - 1) #define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES) - #if !defined(__linux__) && !defined(__CYGWIN__) + #if !defined(__linux__) && !defined(__CYGWIN__) && !defined(_emscripten_) #define dirfd(dirp) ((dirp)->dd_fd) #endif #define D_NAMLEN(dirp) (strlen(dirp->d_name)) diff --git a/util/folder/ya.make b/util/folder/ya.make index c995d26bde..053b93e375 100644 --- a/util/folder/ya.make +++ b/util/folder/ya.make @@ -4,7 +4,7 @@ RECURSE_FOR_TESTS( ut ) -IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT USE_SYSTEM_PYTHON) +IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT OS_EMSCRIPTEN AND NOT USE_SYSTEM_PYTHON) RECURSE( ut_cython ) diff --git a/util/generic/ya.make b/util/generic/ya.make index c995d26bde..053b93e375 100644 --- a/util/generic/ya.make +++ b/util/generic/ya.make @@ -4,7 +4,7 @@ RECURSE_FOR_TESTS( ut ) -IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT USE_SYSTEM_PYTHON) +IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT OS_EMSCRIPTEN AND NOT USE_SYSTEM_PYTHON) RECURSE( ut_cython ) diff --git a/util/memory/ya.make b/util/memory/ya.make index c995d26bde..053b93e375 100644 --- a/util/memory/ya.make +++ b/util/memory/ya.make @@ -4,7 +4,7 @@ RECURSE_FOR_TESTS( ut ) -IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT USE_SYSTEM_PYTHON) +IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT OS_EMSCRIPTEN AND NOT USE_SYSTEM_PYTHON) RECURSE( ut_cython ) diff --git a/util/network/socket.cpp b/util/network/socket.cpp index 4e9ee24ed2..fb9dac7f09 100644 --- a/util/network/socket.cpp +++ b/util/network/socket.cpp @@ -273,6 +273,8 @@ void SetSocketTimeout(SOCKET s, long sec, long msec) { #ifdef SO_SNDTIMEO #ifdef _darwin_ const timeval timeout = {sec, (__darwin_suseconds_t)msec * 1000}; + #elif defined(_emscripten_) + const timeval timeout = {sec, static_cast<suseconds_t>(msec * 1000)}; #elif defined(_unix_) const timeval timeout = {sec, msec * 1000}; #else diff --git a/util/stream/ya.make b/util/stream/ya.make index c995d26bde..053b93e375 100644 --- a/util/stream/ya.make +++ b/util/stream/ya.make @@ -4,7 +4,7 @@ RECURSE_FOR_TESTS( ut ) -IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT USE_SYSTEM_PYTHON) +IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT OS_EMSCRIPTEN AND NOT USE_SYSTEM_PYTHON) RECURSE( ut_cython ) diff --git a/util/string/ya.make b/util/string/ya.make index c995d26bde..053b93e375 100644 --- a/util/string/ya.make +++ b/util/string/ya.make @@ -4,7 +4,7 @@ RECURSE_FOR_TESTS( ut ) -IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT USE_SYSTEM_PYTHON) +IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT OS_EMSCRIPTEN AND NOT USE_SYSTEM_PYTHON) RECURSE( ut_cython ) diff --git a/util/system/error.cpp b/util/system/error.cpp index b5fd974812..c7f22acd32 100644 --- a/util/system/error.cpp +++ b/util/system/error.cpp @@ -81,7 +81,7 @@ void LastSystemErrorText(char* str, size_t size, int code) { Strip(str); #elif defined(_sun_) strfcpy(str, strerror(code), size); -#elif defined(_freebsd_) || defined(_darwin_) || defined(_musl_) || defined(_bionic_) +#elif defined(_freebsd_) || defined(_darwin_) || defined(_musl_) || defined(_bionic_) || defined(_emscripten_) strerror_r(code, str, size); #elif defined(_linux_) | defined(_cygwin_) char* msg = strerror_r(code, str, size); diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp index 957ad4ab32..8e25d84928 100644 --- a/util/system/filemap.cpp +++ b/util/system/filemap.cpp @@ -12,7 +12,7 @@ #include <sys/types.h> #include <sys/mman.h> - #if !defined(_linux_) + #if !defined(_linux_) && !defined(_emscripten_) #ifdef MAP_POPULATE #error unlisted platform supporting MAP_POPULATE #endif diff --git a/util/system/platform.h b/util/system/platform.h index b085cf5b1b..e99f3b7828 100644 --- a/util/system/platform.h +++ b/util/system/platform.h @@ -42,6 +42,10 @@ #if defined(__ANDROID__) #define _android_ #endif + + #if defined(__EMSCRIPTEN__) + #define _emscripten_ + #endif #endif #if defined(__IOS__) @@ -107,7 +111,11 @@ #define _ppc64_ #endif -#if !defined(sparc) && !defined(__sparc) && !defined(__hpux__) && !defined(__alpha__) && !defined(_ia64_) && !defined(_x86_64_) && !defined(_arm_) && !defined(_i386_) && !defined(_ppc_) && !defined(_ppc64_) +#if defined(__wasm64__) + #define _wasm64_ +#endif + +#if !defined(sparc) && !defined(__sparc) && !defined(__hpux__) && !defined(__alpha__) && !defined(_ia64_) && !defined(_x86_64_) && !defined(_arm_) && !defined(_i386_) && !defined(_ppc_) && !defined(_ppc64_) && !defined(_wasm64_) #error "platform not defined, please, define one" #endif @@ -183,7 +191,7 @@ #endif // 16, 32 or 64 -#if defined(__sparc_v9__) || defined(_x86_64_) || defined(_ia64_) || defined(_arm64_) || defined(_ppc64_) +#if defined(__sparc_v9__) || defined(_x86_64_) || defined(_ia64_) || defined(_arm64_) || defined(_ppc64_) || defined(_wasm64_) #define _64_ #else #define _32_ diff --git a/util/system/types.h b/util/system/types.h index 47eb23f018..1cec6adc47 100644 --- a/util/system/types.h +++ b/util/system/types.h @@ -64,7 +64,7 @@ typedef int64_t i64; #define PRITMT PRIi32 #define SCNTMT SCNi32 #elif defined(_64_) - #if defined(_darwin_) + #if defined(_darwin_) || defined(_emscripten_) #define PRISZT "lu" #undef PRIu64 #define PRIu64 PRISZT diff --git a/util/system/ya.make b/util/system/ya.make index c995d26bde..053b93e375 100644 --- a/util/system/ya.make +++ b/util/system/ya.make @@ -4,7 +4,7 @@ RECURSE_FOR_TESTS( ut ) -IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT USE_SYSTEM_PYTHON) +IF (NOT OS_IOS AND NOT OS_ANDROID AND NOT OS_EMSCRIPTEN AND NOT USE_SYSTEM_PYTHON) RECURSE( ut_cython ) diff --git a/util/ut/ya.make b/util/ut/ya.make index dc07708117..eef539f174 100644 --- a/util/ut/ya.make +++ b/util/ut/ya.make @@ -2,6 +2,8 @@ UNITTEST_FOR(util) SUBSCRIBER(g:util-subscribers) +NO_BUILD_IF(OS_EMSCRIPTEN) + SRCS( ysaveload_ut.cpp ) diff --git a/util/ya.make b/util/ya.make index 4e28fc491f..ececf5c17b 100644 --- a/util/ya.make +++ b/util/ya.make @@ -255,7 +255,6 @@ JOIN_SRCS( system/backtrace.cpp system/compat.cpp system/condvar.cpp - system/context.cpp system/daemon.cpp system/datetime.cpp system/defaults.c @@ -264,7 +263,6 @@ JOIN_SRCS( system/env.cpp system/error.cpp system/event.cpp - system/execpath.cpp system/fasttime.cpp system/file.cpp system/file_lock.cpp @@ -278,13 +276,20 @@ JOIN_SRCS( system/hp_timer.cpp system/info.cpp ) +IF (NOT OS_EMSCRIPTEN) +JOIN_SRCS( + all_system_2.cpp + system/context.cpp + system/execpath.cpp +) +ENDIF() IF (OS_WINDOWS) SRCS(system/err.cpp) ENDIF() JOIN_SRCS( - all_system_2.cpp + all_system_3.cpp system/align.cpp system/byteorder.cpp system/cpu_id.cpp @@ -293,7 +298,6 @@ JOIN_SRCS( system/interrupt_signals.cpp system/madvise.cpp system/maxlen.cpp - system/mem_info.cpp system/mincore.cpp system/mktemp.cpp system/mlock.cpp @@ -306,7 +310,6 @@ JOIN_SRCS( system/rusage.cpp system/rwlock.cpp system/sanitizers.cpp - system/sem.cpp system/shellcommand.cpp system/shmat.cpp system/sigset.cpp @@ -316,9 +319,7 @@ JOIN_SRCS( system/sys_alloc.cpp system/sysstat.cpp system/tempfile.cpp - system/thread.cpp system/tls.cpp - system/types.cpp system/type_name.cpp system/unaligned_mem.cpp system/user.cpp @@ -326,6 +327,15 @@ JOIN_SRCS( system/yassert.cpp system/yield.cpp ) +IF (NOT OS_EMSCRIPTEN) +JOIN_SRCS( + all_system_4.cpp + system/mem_info.cpp + system/sem.cpp + system/thread.cpp + system/types.cpp +) +ENDIF() SRC_C_NO_LTO(system/compiler.cpp) |