From 7ed3de15fe61ce28ff9ddc80fbb4c25773db11a7 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Thu, 13 Oct 2022 01:50:39 -0500 Subject: [PATCH] Experimental WebAssembly Support Using emscripten --- .gitignore | 2 + ACE/ace/Notification_Queue.h | 2 + ACE/ace/Timer_Queue_T.inl | 4 ++ ACE/ace/config-emscripten.h | 51 +++++++++++++++++++ ACE/ace/os_include/sys/os_types.h | 2 +- .../makeinclude/platform_emscripten.GNU | 23 +++++++++ 6 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 ACE/ace/config-emscripten.h create mode 100644 ACE/include/makeinclude/platform_emscripten.GNU diff --git a/.gitignore b/.gitignore index 949cea02040ab..6f3b08c679167 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,5 @@ ipch/ *.VC.db* *.tds *.*codeanalysis* +*.js +*.wasm diff --git a/ACE/ace/Notification_Queue.h b/ACE/ace/Notification_Queue.h index 914904ac296fc..18749e4f2a221 100644 --- a/ACE/ace/Notification_Queue.h +++ b/ACE/ace/Notification_Queue.h @@ -13,6 +13,8 @@ #include "ace/Intrusive_List.h" #include "ace/Intrusive_List_Node.h" #include "ace/Unbounded_Queue.h" +#include "ace/Synch_Traits.h" +#include "ace/Thread_Mutex.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Timer_Queue_T.inl b/ACE/ace/Timer_Queue_T.inl index 15c0e8ef99d5f..673820f2e1035 100644 --- a/ACE/ace/Timer_Queue_T.inl +++ b/ACE/ace/Timer_Queue_T.inl @@ -1,6 +1,10 @@ // -*- C++ -*- ACE_BEGIN_VERSIONED_NAMESPACE_DECL +#include "ace/Guard_T.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + template ACE_INLINE FUNCTOR & ACE_Timer_Queue_Upcall_Base::upcall_functor () { diff --git a/ACE/ace/config-emscripten.h b/ACE/ace/config-emscripten.h new file mode 100644 index 0000000000000..f43c16b3a52f6 --- /dev/null +++ b/ACE/ace/config-emscripten.h @@ -0,0 +1,51 @@ +#ifndef ACE_CONFIG_EMSCRIPTEN_H +#define ACE_CONFIG_EMSCRIPTEN_H + +#define ACE_EMSCRIPTEN + +#define ACE_HAS_CPP11 + +// Threading +#define ACE_MT_SAFE 1 +#define ACE_HAS_THREADS 1 +#define ACE_HAS_PTHREADS +#define ACE_HAS_PTHREADS_UNIX98_EXT +#define ACE_HAS_THREAD_SPECIFIC_STORAGE + +// Basic Types +#define ACE_HAS_SSIZE_T +#define ACE_HAS_WCHAR + +// Time +#define ACE_HAS_POSIX_TIME +#define ACE_LACKS_TIMESPEC_T +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_VOIDPTR_GETTIMEOFDAY + +// Everything else +#define ACE_HAS_UCONTEXT_T +#define ACE_HAS_MSG +#define ACE_HAS_CPU_SET_T +#define ACE_LACKS_ISCTYPE +#define ACE_HAS_STRBUF_T +#define ACE_HAS_SOCKLEN_T +#define ACE_LACKS_AUTO_PTR +#define ACE_HAS_SIGINFO_T +#define ACE_LACKS_SIGINFO_H +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES +#define ACE_HAS_3_PARAM_WCSTOK +#define ACE_LACKS_ITOW +#define ACE_LACKS_WCSICMP +#define ACE_LACKS_WCSNICMP +#define ACE_HAS_DIRENT +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG + +#include "config-posix.h" +#include "config-g++-common.h" + +// Not supported? https://github.com/emscripten-core/emscripten/issues/18050 +#ifdef ACE_HAS_AIO_CALLS +# undef ACE_HAS_AIO_CALLS +#endif + +#endif diff --git a/ACE/ace/os_include/sys/os_types.h b/ACE/ace/os_include/sys/os_types.h index 822c8a93d97db..7f39c8cc99957 100644 --- a/ACE/ace/os_include/sys/os_types.h +++ b/ACE/ace/os_include/sys/os_types.h @@ -66,7 +66,7 @@ typedef double ACE_timer_t; #if defined (ACE_SIZEOF_LONG) && ACE_SIZEOF_LONG == 8 typedef off_t ACE_LOFF_T; #elif defined (ACE_HAS_RTEMS) || defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__APPLE__) || \ - (defined (ACE_OPENVMS) && defined (_LARGEFILE)) + (defined (ACE_OPENVMS) && defined (_LARGEFILE)) || defined (ACE_EMSCRIPTEN) typedef off_t ACE_LOFF_T; #elif defined (AIX) || defined (HPUX) || defined (__QNX__) typedef off64_t ACE_LOFF_T; diff --git a/ACE/include/makeinclude/platform_emscripten.GNU b/ACE/include/makeinclude/platform_emscripten.GNU new file mode 100644 index 0000000000000..af6fa2bc14544 --- /dev/null +++ b/ACE/include/makeinclude/platform_emscripten.GNU @@ -0,0 +1,23 @@ +ACE_PLATFORM_CONFIG ?= config-emscripten.h +EXEEXT = .js + +debug ?= 1 +optimize ?= 1 +threads ?= 1 +inline ?= 1 +static_libs_only = 1 + +CROSS_COMPILE := THIS_VALUE_SHOULD_NOT_BE_USED +override_cross_compile = 1 +CC = emcc +CXX = em++ +AR = emar +LD = emcc + +ifeq ($(threads),1) + FLAGS_C_CC += -pthread + SOFLAGS += -pthread + LIBS += -lrt +endif + +include $(ACE_ROOT)/include/makeinclude/platform_clang_common.GNU