add boost asio to speech2

currently the main program is just some stackful coro example stuff that i used just to test

i'll add beast too in a sec but just. hang on
This commit is contained in:
Lily Tsuru 2024-07-20 06:37:09 -04:00
parent b4a6860e75
commit ddd3483620
79 changed files with 639 additions and 14 deletions

198
.gitmodules vendored Normal file
View file

@ -0,0 +1,198 @@
[submodule "speech2/third_party/boost/algorithm"]
path = speech2/third_party/boost/algorithm
url = https://github.com/boostorg/algorithm.git
[submodule "speech2/third_party/boost/align"]
path = speech2/third_party/boost/align
url = https://github.com/boostorg/align.git
[submodule "speech2/third_party/boost/array"]
path = speech2/third_party/boost/array
url = https://github.com/boostorg/array.git
[submodule "speech2/third_party/boost/assert"]
path = speech2/third_party/boost/assert
url = https://github.com/boostorg/assert.git
[submodule "speech2/third_party/boost/atomic"]
path = speech2/third_party/boost/atomic
url = https://github.com/boostorg/atomic.git
[submodule "speech2/third_party/boost/bind"]
path = speech2/third_party/boost/bind
url = https://github.com/boostorg/bind.git
[submodule "speech2/third_party/boost/charconv"]
path = speech2/third_party/boost/charconv
url = https://github.com/boostorg/charconv.git
[submodule "speech2/third_party/boost/chrono"]
path = speech2/third_party/boost/chrono
url = https://github.com/boostorg/chrono.git
[submodule "speech2/third_party/boost/circular_buffer"]
path = speech2/third_party/boost/circular_buffer
url = https://github.com/boostorg/circular_buffer.git
[submodule "speech2/third_party/boost/concept_check"]
path = speech2/third_party/boost/concept_check
url = https://github.com/boostorg/concept_check.git
[submodule "speech2/third_party/boost/config"]
path = speech2/third_party/boost/config
url = https://github.com/boostorg/config.git
[submodule "speech2/third_party/boost/container"]
path = speech2/third_party/boost/container
url = https://github.com/boostorg/container.git
[submodule "speech2/third_party/boost/container_hash"]
path = speech2/third_party/boost/container_hash
url = https://github.com/boostorg/container_hash.git
[submodule "speech2/third_party/boost/context"]
path = speech2/third_party/boost/context
url = https://github.com/boostorg/context.git
[submodule "speech2/third_party/boost/conversion"]
path = speech2/third_party/boost/conversion
url = https://github.com/boostorg/conversion.git
[submodule "speech2/third_party/boost/core"]
path = speech2/third_party/boost/core
url = https://github.com/boostorg/core.git
[submodule "speech2/third_party/boost/coroutine"]
path = speech2/third_party/boost/coroutine
url = https://github.com/boostorg/coroutine.git
[submodule "speech2/third_party/boost/date_time"]
path = speech2/third_party/boost/date_time
url = https://github.com/boostorg/date_time.git
[submodule "speech2/third_party/boost/describe"]
path = speech2/third_party/boost/describe
url = https://github.com/boostorg/describe.git
[submodule "speech2/third_party/boost/detail"]
path = speech2/third_party/boost/detail
url = https://github.com/boostorg/detail.git
[submodule "speech2/third_party/boost/endian"]
path = speech2/third_party/boost/endian
url = https://github.com/boostorg/endian.git
[submodule "speech2/third_party/boost/exception"]
path = speech2/third_party/boost/exception
url = https://github.com/boostorg/exception.git
[submodule "speech2/third_party/boost/filesystem"]
path = speech2/third_party/boost/filesystem
url = https://github.com/boostorg/filesystem.git
[submodule "speech2/third_party/boost/function"]
path = speech2/third_party/boost/function
url = https://github.com/boostorg/function.git
[submodule "speech2/third_party/boost/functional"]
path = speech2/third_party/boost/functional
url = https://github.com/boostorg/functional.git
[submodule "speech2/third_party/boost/function_types"]
path = speech2/third_party/boost/function_types
url = https://github.com/boostorg/function_types.git
[submodule "speech2/third_party/boost/fusion"]
path = speech2/third_party/boost/fusion
url = https://github.com/boostorg/fusion.git
[submodule "speech2/third_party/boost/integer"]
path = speech2/third_party/boost/integer
url = https://github.com/boostorg/integer.git
[submodule "speech2/third_party/boost/intrusive"]
path = speech2/third_party/boost/intrusive
url = https://github.com/boostorg/intrusive.git
[submodule "speech2/third_party/boost/io"]
path = speech2/third_party/boost/io
url = https://github.com/boostorg/io.git
[submodule "speech2/third_party/boost/iterator"]
path = speech2/third_party/boost/iterator
url = https://github.com/boostorg/iterator.git
[submodule "speech2/third_party/boost/json"]
path = speech2/third_party/boost/json
url = https://github.com/boostorg/json.git
[submodule "speech2/third_party/boost/leaf"]
path = speech2/third_party/boost/leaf
url = https://github.com/boostorg/leaf.git
[submodule "speech2/third_party/boost/lexical_cast"]
path = speech2/third_party/boost/lexical_cast
url = https://github.com/boostorg/lexical_cast.git
[submodule "speech2/third_party/boost/lockfree"]
path = speech2/third_party/boost/lockfree
url = https://github.com/boostorg/lockfree.git
[submodule "speech2/third_party/boost/logic"]
path = speech2/third_party/boost/logic
url = https://github.com/boostorg/logic.git
[submodule "speech2/third_party/boost/move"]
path = speech2/third_party/boost/move
url = https://github.com/boostorg/move.git
[submodule "speech2/third_party/boost/mp11"]
path = speech2/third_party/boost/mp11
url = https://github.com/boostorg/mp11.git
[submodule "speech2/third_party/boost/mpl"]
path = speech2/third_party/boost/mpl
url = https://github.com/boostorg/mpl.git
[submodule "speech2/third_party/boost/numeric_conversion"]
path = speech2/third_party/boost/numeric_conversion
url = https://github.com/boostorg/numeric_conversion.git
[submodule "speech2/third_party/boost/optional"]
path = speech2/third_party/boost/optional
url = https://github.com/boostorg/optional.git
[submodule "speech2/third_party/boost/parameter"]
path = speech2/third_party/boost/parameter
url = https://github.com/boostorg/parameter.git
[submodule "speech2/third_party/boost/pool"]
path = speech2/third_party/boost/pool
url = https://github.com/boostorg/pool.git
[submodule "speech2/third_party/boost/predef"]
path = speech2/third_party/boost/predef
url = https://github.com/boostorg/predef.git
[submodule "speech2/third_party/boost/preprocessor"]
path = speech2/third_party/boost/preprocessor
url = https://github.com/boostorg/preprocessor.git
[submodule "speech2/third_party/boost/range"]
path = speech2/third_party/boost/range
url = https://github.com/boostorg/range.git
[submodule "speech2/third_party/boost/ratio"]
path = speech2/third_party/boost/ratio
url = https://github.com/boostorg/ratio.git
[submodule "speech2/third_party/boost/rational"]
path = speech2/third_party/boost/rational
url = https://github.com/boostorg/rational.git
[submodule "speech2/third_party/boost/regex"]
path = speech2/third_party/boost/regex
url = https://github.com/boostorg/regex.git
[submodule "speech2/third_party/boost/scope"]
path = speech2/third_party/boost/scope
url = https://github.com/boostorg/scope.git
[submodule "speech2/third_party/boost/smart_ptr"]
path = speech2/third_party/boost/smart_ptr
url = https://github.com/boostorg/smart_ptr.git
[submodule "speech2/third_party/boost/static_assert"]
path = speech2/third_party/boost/static_assert
url = https://github.com/boostorg/static_assert.git
[submodule "speech2/third_party/boost/static_string"]
path = speech2/third_party/boost/static_string
url = https://github.com/boostorg/static_string.git
[submodule "speech2/third_party/boost/system"]
path = speech2/third_party/boost/system
url = https://github.com/boostorg/system.git
[submodule "speech2/third_party/boost/throw_exception"]
path = speech2/third_party/boost/throw_exception
url = https://github.com/boostorg/throw_exception.git
[submodule "speech2/third_party/boost/tokenizer"]
path = speech2/third_party/boost/tokenizer
url = https://github.com/boostorg/tokenizer.git
[submodule "speech2/third_party/boost/tuple"]
path = speech2/third_party/boost/tuple
url = https://github.com/boostorg/tuple.git
[submodule "speech2/third_party/boost/type_index"]
path = speech2/third_party/boost/type_index
url = https://github.com/boostorg/type_index.git
[submodule "speech2/third_party/boost/typeof"]
path = speech2/third_party/boost/typeof
url = https://github.com/boostorg/typeof.git
[submodule "speech2/third_party/boost/type_traits"]
path = speech2/third_party/boost/type_traits
url = https://github.com/boostorg/type_traits.git
[submodule "speech2/third_party/boost/unordered"]
path = speech2/third_party/boost/unordered
url = https://github.com/boostorg/unordered.git
[submodule "speech2/third_party/boost/url"]
path = speech2/third_party/boost/url
url = https://github.com/boostorg/url.git
[submodule "speech2/third_party/boost/utility"]
path = speech2/third_party/boost/utility
url = https://github.com/boostorg/utility.git
[submodule "speech2/third_party/boost/variant2"]
path = speech2/third_party/boost/variant2
url = https://github.com/boostorg/variant2.git
[submodule "speech2/third_party/boost/winapi"]
path = speech2/third_party/boost/winapi
url = https://github.com/boostorg/winapi.git
[submodule "speech2/third_party/boost/asio"]
path = speech2/third_party/boost/asio
url = https://github.com/boostorg/asio.git

View file

@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.15)
project(speech2) project(speech2)
xp_init()
enable_language(ASM) enable_language(ASM)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
@ -9,7 +13,7 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(Policies) include(Policies)
include(ProjectFuncs) include(ProjectFuncs)
add_subdirectory(third_party/boost)
add_subdirectory(src) add_subdirectory(src)

View file

@ -18,11 +18,12 @@ if("$ENV{VCDIR}" STREQUAL "")
endif() endif()
set(_CRTDIR "$ENV{VCDIR}/crt") set(_CRTDIR "$ENV{VCDIR}/crt")
#-isystem ${_CRTDIR}/include
set(_UCRTDIR "$ENV{VCDIR}/ucrt") set(_UCRTDIR "$ENV{VCDIR}/ucrt")
set(_PSDKDIR "$ENV{VCDIR}/winsdk") set(_PSDKDIR "$ENV{VCDIR}/winsdk")
set(_CLANG_BASEFLAGS "-target ${_MSVC_TRIPLET} -fms-extensions -fms-compatibility-version=19 -isystem ${_CRTDIR}/include -isystem ${_UCRTDIR}/include -isystem ${_PSDKDIR}/include/shared -isystem ${_PSDKDIR}/include/um") set(_CLANG_BASEFLAGS "-target ${_MSVC_TRIPLET} -fms-extensions -fms-compatibility -fms-compatibility-version=19 -isystem $ENV{VCDIR}/libcxx/include/c++ -isystem ${_UCRTDIR}/include -isystem $ENV{VCDIR}/libcxx/include -isystem ${_PSDKDIR}/include/shared -isystem ${_PSDKDIR}/include/um ")
set(_CLANG_ARCHFLAGS "-march=pentium4") set(_CLANG_ARCHFLAGS "-march=pentium4 -D_WIN32_WINNT=0x0501")
set(CMAKE_C_COMPILER "clang" CACHE FILEPATH "") set(CMAKE_C_COMPILER "clang" CACHE FILEPATH "")
set(CMAKE_CXX_COMPILER "clang++" CACHE FILEPATH "") set(CMAKE_CXX_COMPILER "clang++" CACHE FILEPATH "")
@ -36,12 +37,18 @@ set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT} ${CMAKE_CXX_FLAG
# Set base linker library paths # Set base linker library paths
foreach(type EXE MODULE SHARED) foreach(type EXE MODULE SHARED)
# -Xlinker /nodefaultlib:libcpmt -Xlinker /nodefaultlib:libcpmtd
set(CMAKE_${type}_LINKER_FLAGS "-Xlinker /libpath:${_CRTDIR}/lib/x86 -Xlinker /libpath:${_UCRTDIR}/lib -Xlinker /libpath:${_PSDKDIR}/lib") set(CMAKE_${type}_LINKER_FLAGS "-Xlinker /libpath:${_CRTDIR}/lib/x86 -Xlinker /libpath:${_UCRTDIR}/lib -Xlinker /libpath:${_PSDKDIR}/lib")
endforeach() endforeach()
# Remove fluff libraries; projects should specify them # Remove fluff libraries; projects should specify them
set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING "" FORCE) set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(CMAKE_CXX_STANDARD_LIBRARIES "-Xlinker /libpath:$ENV{VCDIR}/libcxx/lib -Xlinker libcpmtd.lib -Xlinker libc++d.lib -Xlinker winpthreadsd.lib" CACHE STRING "" FORCE)
else()
set(CMAKE_CXX_STANDARD_LIBRARIES "-Xlinker /libpath:$ENV{VCDIR}/libcxx/lib -Xlinker libcpmt.lib -Xlinker libc++.lib -Xlinker winpthreads.lib" CACHE STRING "" FORCE)
endif()
# Run this once after you call project() to replace broken # Run this once after you call project() to replace broken
macro(xp_init) macro(xp_init)
@ -50,12 +57,22 @@ macro(xp_init)
# because .... # because ....
set(CMAKE_${lang}_CREATE_SHARED_LIBRARY set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
"<CMAKE_${lang}_COMPILER> -nostartfiles -nostdlib <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} -Xlinker /MANIFEST:EMBED -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:${CMAKE_SYSTEM_VERSION} <OBJECTS> <LINK_LIBRARIES> <MANIFESTS>" CACHE STRING "" FORCE) "<CMAKE_${lang}_COMPILER> -nostartfiles -nostdlib <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} -Xlinker /MANIFEST:EMBED -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:${CMAKE_SYSTEM_VERSION} <OBJECTS> <LINK_LIBRARIES> <MANIFESTS>" CACHE STRING "" FORCE)
set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY} CACHE STRING "") set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY} CACHE STRING "" FORCE)
set(CMAKE_${lang}_LINK_EXECUTABLE set(CMAKE_${lang}_LINK_EXECUTABLE
"<CMAKE_${lang}_COMPILER> -nostartfiles -nostdlib <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Xlinker /MANIFEST:NO -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:${CMAKE_SYSTEM_VERSION} ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES> <MANIFESTS>" CACHE STRING "" FORCE) "<CMAKE_${lang}_COMPILER> -nostartfiles -nostdlib <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Xlinker /MANIFEST:NO -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:${CMAKE_SYSTEM_VERSION} ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES> <MANIFESTS>" CACHE STRING "" FORCE)
# also patch these so we can set the subsytem version # also patch these so we can set the subsytem version
set(CMAKE_${lang}_CREATE_WIN32_EXE "-Xlinker /subsystem:windows,${CMAKE_SYSTEM_VERSION}" CACHE STRING "") set(CMAKE_${lang}_CREATE_WIN32_EXE "-Xlinker /subsystem:windows,${CMAKE_SYSTEM_VERSION}" CACHE STRING "" FORCE)
set(CMAKE_${lang}_CREATE_CONSOLE_EXE "-Xlinker /subsystem:console,${CMAKE_SYSTEM_VERSION}" CACHE STRING "") set(CMAKE_${lang}_CREATE_CONSOLE_EXE "-Xlinker /subsystem:console,${CMAKE_SYSTEM_VERSION}" CACHE STRING "" FORCE)
endforeach() endforeach()
endmacro() endmacro()
# Use the static multithreaded C library
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# dummy
set(CMAKE_ASM_MASM_COMPILE_OBJECT "${CMAKE_ASM_COMPILE_OBJECT}")
xp_init()

View file

@ -1,20 +1,39 @@
add_subdirectory(sapi4) add_subdirectory(sapi4)
xp_init()
add_executable(sapiserver add_executable(sapiserver
main.cpp main.cpp
winxp_compat_fwd.asm winxp_compat_fwd.S
winxp_compat.cpp winxp_compat.cpp
winxp_compat_threadsafe_static.c
) )
speech2_target(sapiserver) speech2_target(sapiserver)
target_compile_definitions(sapiserver PRIVATE
# Need to force this on, since I think clang's msvc compatibility
# is deciding to set a wrong __cplusplus (like MSVC, so it's not *exactly* clang's fault).
# The best way to fix it would probably involve using clang-cl frontend and passing the option (I think.)
-DBOOST_ASIO_HAS_STD_INVOKE_RESULT=1
# Disable the "helpful" auto-link Boost.Config tries to do. CMake already has a functional
# dependency graph, so we don't need it.
-DBOOST_ALL_NO_LIB=1
)
target_link_libraries(sapiserver PRIVATE target_link_libraries(sapiserver PRIVATE
# runtime libs
libc++
# subprojects
speech2_sapi4 speech2_sapi4
# SDK libraries
uuid.lib uuid.lib
ole32.lib ole32.lib
Boost::asio
Boost::coroutine
Boost::context
) )

View file

@ -1,13 +1,109 @@
#include <stdio.h> #include <stdio.h>
#include <windows.h>
#include <boost/asio/detached.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/spawn.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/asio/write.hpp>
#include <iostream>
#include <memory> #include <memory>
#include "speechapi.hpp" #include "speechapi.hpp"
int main() { using boost::asio::ip::tcp;
CoInitialize(nullptr);
class session : public std::enable_shared_from_this<session> {
public:
explicit session(boost::asio::io_context& io_context, tcp::socket socket)
: socket_(std::move(socket)), timer_(io_context), strand_(io_context.get_executor()) {}
void go() {
auto self(shared_from_this());
boost::asio::spawn(
strand_,
[this, self](boost::asio::yield_context yield) {
try {
char data[128];
for(;;) {
timer_.expires_after(std::chrono::seconds(10));
std::size_t n = socket_.async_read_some(boost::asio::buffer(data), yield);
boost::asio::async_write(socket_, boost::asio::buffer(data, n), yield);
}
} catch(std::exception& e) {
socket_.close();
timer_.cancel();
}
},
boost::asio::detached);
boost::asio::spawn(
strand_,
[this, self](boost::asio::yield_context yield) {
while(socket_.is_open()) {
boost::system::error_code ignored_ec;
timer_.async_wait(yield[ignored_ec]);
if(timer_.expiry() <= boost::asio::steady_timer::clock_type::now())
socket_.close();
}
},
boost::asio::detached);
}
private:
tcp::socket socket_;
boost::asio::steady_timer timer_;
boost::asio::strand<boost::asio::io_context::executor_type> strand_;
};
int main(int argc, char** argv) {
// CoInitialize(nullptr);
#if 0
boost::asio::io_context iocMain(1);
printf("inited io context\n");
iocMain.post([&]() {
printf("Hello from Boost.ASIO + C++20 on XP\n");
iocMain.stop();
});
iocMain.run();
#endif
try {
if(argc != 2) {
std::cerr << "Usage: echo_server <port>\n";
return 1;
}
boost::asio::io_context io_context;
boost::asio::spawn(
io_context,
[&](boost::asio::yield_context yield) {
tcp::acceptor acceptor(io_context, tcp::endpoint(tcp::v4(), std::atoi(argv[1])));
for(;;) {
boost::system::error_code ec;
tcp::socket socket(io_context);
acceptor.async_accept(socket, yield[ec]);
if(!ec) {
std::make_shared<session>(io_context, std::move(socket))->go();
}
}
},
[](std::exception_ptr e) {
if(e)
std::rethrow_exception(e);
});
io_context.run();
} catch(std::exception& e) {
std::cerr << "Exception: " << e.what() << "\n";
}
#if 0 // test spech shit
auto api = std::unique_ptr<ISpeechAPI>(ISpeechAPI::CreateSapi4()); auto api = std::unique_ptr<ISpeechAPI>(ISpeechAPI::CreateSapi4());
if(auto hr = api->Initialize(); FAILED(hr)) { if(auto hr = api->Initialize(); FAILED(hr)) {
@ -22,7 +118,8 @@ int main() {
} }
printf("Selected voice\n"); printf("Selected voice\n");
#endif
CoUninitialize(); // CoUninitialize();
return 0; return 0;
} }

View file

@ -25,4 +25,10 @@ BOOL WINAPI LibInitalizeCriticalSectionEx(LPCRITICAL_SECTION lpCriticalSection,
return pfnInitalizeCriticalSectionEx(lpCriticalSection, dwSpinCount, dwFlags); return pfnInitalizeCriticalSectionEx(lpCriticalSection, dwSpinCount, dwFlags);
} }
void WINAPI LibGetSystemTimePreciseAsFileTime(LPFILETIME lpSystemTimeAsFileTime) {
// TODO: Above
return GetSystemTimeAsFileTime(lpSystemTimeAsFileTime);
}
} }

View file

@ -3,3 +3,7 @@
.globl "__imp__InitializeCriticalSectionEx@12" .globl "__imp__InitializeCriticalSectionEx@12"
"__imp__InitializeCriticalSectionEx@12": "__imp__InitializeCriticalSectionEx@12":
.long "_LibInitalizeCriticalSectionEx@12" .long "_LibInitalizeCriticalSectionEx@12"
.globl "__imp__GetSystemTimePreciseAsFileTime@4"
"__imp__GetSystemTimePreciseAsFileTime@4":
.long "_LibGetSystemTimePreciseAsFileTime@4"

View file

@ -0,0 +1,104 @@
/* This file provides routines used for thread-safe initialisation of static
* variables when /Zc:threadSafeInit is used (enabled by default).
*
* This is intended to override the default implementations from the Microsoft
* C++ Runtime which are compiled to target Windows Vista or later.
*
* Modeled on the reference implementation in thread_safe_statics.cpp in the
* Microsoft C++ Runtime.
*/
#include <assert.h>
#include <limits.h>
//#include <pthread.h>
static const int UNINITIALIZED = 0;
static const int INITIALIZING = -1;
static const int EPOCH_BASE = INT_MIN;
/* Exposed as a public symbol in the reference implementation, so exposed it
* has to stay here too...
*/
int _Init_global_epoch = EPOCH_BASE;
__declspec(thread) int _Init_thread_epoch = EPOCH_BASE;
//static pthread_mutex_t _Init_thread_mutex = PTHREAD_MUTEX_INITIALIZER;
//static pthread_cond_t _Init_thread_cond = PTHREAD_COND_INITIALIZER;
void __cdecl _Init_thread_lock()
{
// pthread_mutex_lock(&_Init_thread_mutex);
}
void __cdecl _Init_thread_unlock()
{
//pthread_mutex_unlock(&_Init_thread_mutex);
}
void __cdecl _Init_thread_wait_v2()
{
//pthread_cond_wait(&_Init_thread_cond, &_Init_thread_mutex);
}
void __cdecl _Init_thread_notify()
{
// pthread_cond_broadcast(&_Init_thread_cond);
}
void __cdecl _Init_thread_header(int* const pOnce)
{
_Init_thread_lock();
if (*pOnce == UNINITIALIZED)
{
*pOnce = INITIALIZING;
}
else
{
while (*pOnce == INITIALIZING)
{
_Init_thread_wait_v2();
if (*pOnce == UNINITIALIZED)
{
*pOnce = INITIALIZING;
_Init_thread_unlock();
return;
}
}
_Init_thread_epoch = _Init_global_epoch;
}
_Init_thread_unlock();
}
void __cdecl _Init_thread_abort(int* const pOnce)
{
_Init_thread_lock();
*pOnce = UNINITIALIZED;
_Init_thread_unlock();
_Init_thread_notify();
}
void __cdecl _Init_thread_footer(int* const pOnce)
{
_Init_thread_lock();
++_Init_global_epoch;
/* Probably unlikely condition... you would need to construct ~2 billion
* static objects before the "epoch" would roll up to the "INITIALIZING"
* constant and cause weird behaviour... the official implementation
* technically has this bug too.
*/
assert(_Init_global_epoch < INITIALIZING);
*pOnce = _Init_global_epoch;
_Init_thread_epoch = _Init_global_epoch;
_Init_thread_unlock();
_Init_thread_notify();
}

View file

@ -0,0 +1,13 @@
# Hack but it works :)
set(BOOST_SUPERPROJECT_VERSION 1.85.0)
# Boost Context Have Sucks
set(BOOST_CONTEXT_ASSEMBLER clang_gas CACHE STRING "")
set(BOOST_CONTEXT_ASM_SUFFIX .S CACHE STRING "")
# Populate library list
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/list _COLLABVM3_BOOST_LIBRARY_LIST)
foreach(lib ${_COLLABVM3_BOOST_LIBRARY_LIST})
message(STATUS "Adding boost module ${lib}")
add_subdirectory(${lib})
endforeach()

11
speech2/third_party/boost/README.md vendored Normal file
View file

@ -0,0 +1,11 @@
# Welcome to hell
This is where all the boost libraries used by the server live
see ./list for them
# Reinitalizing
The following bash one liner was used to initalize this repo
`for f in $(cat list); do git submodule add https://github.com/boostorg/$f.git $f; cd $f; git checkout boost-1.82.0; cd ..; done`

10
speech2/third_party/boost/add.sh vendored Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
# note that this doesn't add the library to ./list
# you will need to do that yourself
# (it could be added but bleh)
lib=$1
git submodule add https://github.com/boostorg/$lib.git $lib
# remember to bump the version afterwards

@ -0,0 +1 @@
Subproject commit 32c5a6327cfdca5d41ce0f1d8849b811886daa2f

1
speech2/third_party/boost/align vendored Submodule

@ -0,0 +1 @@
Subproject commit 5ad7df63cd792fbdb801d600b93cad1a432f0151

1
speech2/third_party/boost/array vendored Submodule

@ -0,0 +1 @@
Subproject commit 23f6b27c0d9916b9932baac898ae3009817a9153

1
speech2/third_party/boost/asio vendored Submodule

@ -0,0 +1 @@
Subproject commit e65367991cb5fbdb8a7cf218ae38f69ca9a0a9f5

1
speech2/third_party/boost/assert vendored Submodule

@ -0,0 +1 @@
Subproject commit 447e0b3a331930f8708ade0e42683d12de9dfbc3

1
speech2/third_party/boost/atomic vendored Submodule

@ -0,0 +1 @@
Subproject commit 5bbcce0f6e855dc4009e2e6977c62e0520c39573

1
speech2/third_party/boost/bind vendored Submodule

@ -0,0 +1 @@
Subproject commit 9fbfdcb3577e9427815d4f8cc25b3a25d5b9696b

10
speech2/third_party/boost/bump_version.sh vendored Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
# bump all the repositories
for library in $(cat $PWD/list); do
pushd $library >/dev/null 2>&1
git checkout develop
git pull
git checkout $1
popd >/dev/null 2>&1
done

1
speech2/third_party/boost/charconv vendored Submodule

@ -0,0 +1 @@
Subproject commit ecdca0865d4d8fcfbf8e5b48914f2b5711c418ad

1
speech2/third_party/boost/chrono vendored Submodule

@ -0,0 +1 @@
Subproject commit ee0d6d543a37d9b7243682549e9ae359eb89daa9

@ -0,0 +1 @@
Subproject commit a08a5b55ee82e0c2487523471379ac53a23935dc

@ -0,0 +1 @@
Subproject commit 37c9bddf0bdefaaae0ca5852c1a153d9fc43f278

1
speech2/third_party/boost/config vendored Submodule

@ -0,0 +1 @@
Subproject commit 11385ec21012926e15a612e3bf9f9a71403c1e5b

@ -0,0 +1 @@
Subproject commit 6e697d796897b32b471b4f0740dcaa03d8ee57cc

@ -0,0 +1 @@
Subproject commit 6d214eb776456bf17fbee20780a034a23438084f

1
speech2/third_party/boost/context vendored Submodule

@ -0,0 +1 @@
Subproject commit 1bde50e400547e29336afe7ea0cd693d8c884fb6

@ -0,0 +1 @@
Subproject commit 9f285ef0c43c101e49b37bf5e6085e8d635887dc

1
speech2/third_party/boost/core vendored Submodule

@ -0,0 +1 @@
Subproject commit 083b41c17e34f1fc9b43ab796b40d0d8bece685c

@ -0,0 +1 @@
Subproject commit 1e1347c0b1910b9310ec1719edad8b0bf2fd03c8

@ -0,0 +1 @@
Subproject commit 85e637cb325208c2af9af791c3a1948b4888c6cd

1
speech2/third_party/boost/describe vendored Submodule

@ -0,0 +1 @@
Subproject commit 50719b212349f3d1268285c586331584d3dbfeb5

1
speech2/third_party/boost/detail vendored Submodule

@ -0,0 +1 @@
Subproject commit 9c3a0022b25d3e483f9100cc363bc93a72fd900a

1
speech2/third_party/boost/endian vendored Submodule

@ -0,0 +1 @@
Subproject commit c9b436e5dfce85e8ae365e5aabbb872dd35c29eb

@ -0,0 +1 @@
Subproject commit b9170a02f102250b308c9f94ed6593c5f30eab39

@ -0,0 +1 @@
Subproject commit a0c8edba38a4d31b449fcf7b7ada455977342596

1
speech2/third_party/boost/function vendored Submodule

@ -0,0 +1 @@
Subproject commit 28b88d07bb4807445462c3f5dab0efde6f532d32

@ -0,0 +1 @@
Subproject commit 895335874d67987ada0d8bf6ca1725e70642ed49

@ -0,0 +1 @@
Subproject commit 6a573e4b8333ee63ee62ce95558c3667348db233

1
speech2/third_party/boost/fusion vendored Submodule

@ -0,0 +1 @@
Subproject commit 7d4c03fa032299f2d46149b7b3136c9fd43e4f81

1
speech2/third_party/boost/integer vendored Submodule

@ -0,0 +1 @@
Subproject commit dea8e3445dc3ca29201498260307138b9460a70c

@ -0,0 +1 @@
Subproject commit 07ba0e376177409c396c109807c13b7181a98ebe

1
speech2/third_party/boost/io vendored Submodule

@ -0,0 +1 @@
Subproject commit 342e4c6d10d586058818daa84201a2d301357a53

1
speech2/third_party/boost/iterator vendored Submodule

@ -0,0 +1 @@
Subproject commit 4f7219965a399051bb0d8088ea4ab3929b1ac3f2

1
speech2/third_party/boost/json vendored Submodule

@ -0,0 +1 @@
Subproject commit 9f85ed6d62ff91c6dc4fc30e3a20e9049ec67585

1
speech2/third_party/boost/leaf vendored Submodule

@ -0,0 +1 @@
Subproject commit ed8f9cd32f4fde695d497502f696f6f861b68559

@ -0,0 +1 @@
Subproject commit 02e5821ab32c45fad719829e9644e5d681c9ba0b

66
speech2/third_party/boost/list vendored Normal file
View file

@ -0,0 +1,66 @@
algorithm
align
array
assert
atomic
bind
charconv
chrono
circular_buffer
concept_check
config
container
container_hash
context
conversion
core
coroutine
date_time
describe
detail
endian
exception
filesystem
function
functional
function_types
fusion
integer
intrusive
io
iterator
json
leaf
lexical_cast
lockfree
logic
move
mp11
mpl
numeric_conversion
optional
parameter
pool
predef
preprocessor
range
ratio
rational
regex
scope
smart_ptr
static_assert
static_string
system
throw_exception
tokenizer
tuple
type_index
typeof
type_traits
unordered
url
utility
variant2
winapi
asio

1
speech2/third_party/boost/lockfree vendored Submodule

@ -0,0 +1 @@
Subproject commit fdd4d0632dd0904f6e9c656c45397fe8ef985bc9

1
speech2/third_party/boost/logic vendored Submodule

@ -0,0 +1 @@
Subproject commit 145778490c2d332c1411df6a5274a4b53ec3e091

1
speech2/third_party/boost/move vendored Submodule

@ -0,0 +1 @@
Subproject commit 7c01072629d83a7b54c99de70ef535d699ebd200

1
speech2/third_party/boost/mp11 vendored Submodule

@ -0,0 +1 @@
Subproject commit 863d8b8d2b20f2acd0b5870f23e553df9ce90e6c

1
speech2/third_party/boost/mpl vendored Submodule

@ -0,0 +1 @@
Subproject commit b440c45c2810acbddc917db057f2e5194da1a199

@ -0,0 +1 @@
Subproject commit 50a1eae942effb0a9b90724323ef8f2a67e7984a

1
speech2/third_party/boost/optional vendored Submodule

@ -0,0 +1 @@
Subproject commit c60db27762ff9cc16529e069c3c15f2fa898f994

@ -0,0 +1 @@
Subproject commit c07f2b8d37ded87f6f9d5bac867550f6e61282c1

1
speech2/third_party/boost/pool vendored Submodule

@ -0,0 +1 @@
Subproject commit ec7da07ed13e0c61e50d945b574a12ae7ec83cf4

1
speech2/third_party/boost/predef vendored Submodule

@ -0,0 +1 @@
Subproject commit 0fdfb49c3a6789e50169a44e88a07cc889001106

@ -0,0 +1 @@
Subproject commit c4ea7e40d365ba28faecef8917d5c3f1e0121bf9

1
speech2/third_party/boost/range vendored Submodule

@ -0,0 +1 @@
Subproject commit 2bb6b636796f7b008196888613f51f5bb347c77d

1
speech2/third_party/boost/ratio vendored Submodule

@ -0,0 +1 @@
Subproject commit d5b33caa7d564be9be6d962b18659b7741d764ac

1
speech2/third_party/boost/rational vendored Submodule

@ -0,0 +1 @@
Subproject commit 564623136417068916495e2b24737054d607347c

1
speech2/third_party/boost/regex vendored Submodule

@ -0,0 +1 @@
Subproject commit 4cbcd3078e6ae10d05124379623a1bf03fcb9350

1
speech2/third_party/boost/scope vendored Submodule

@ -0,0 +1 @@
Subproject commit 8321450aca6fc6a075225ba225036e585ce1716b

@ -0,0 +1 @@
Subproject commit 3ef8cfd02f9cb3e0486c26f35ed4c27c6f26bd5f

@ -0,0 +1 @@
Subproject commit ba72d3340f3dc6e773868107f35902292f84b07e

@ -0,0 +1 @@
Subproject commit ac84c4f40ec38f7a7237255738e3e5259aa4a1a8

1
speech2/third_party/boost/system vendored Submodule

@ -0,0 +1 @@
Subproject commit 2fc720a1cbe51d588fecc4e0af9417bd769381d8

@ -0,0 +1 @@
Subproject commit 7c8ec2114bc1f9ab2a8afbd629b96fbdd5901294

@ -0,0 +1 @@
Subproject commit 90106f155bd72b62aaca0d9ad826f4132030dba0

1
speech2/third_party/boost/tuple vendored Submodule

@ -0,0 +1 @@
Subproject commit b67941dd7d03536a854b96f001954792311ab515

@ -0,0 +1 @@
Subproject commit e37bc99e85e85bcac420ac1d4c1a8a5bca280d47

@ -0,0 +1 @@
Subproject commit cc6fc3daa8e20c4a70b563d67ceb4c34d8c1c4d7

1
speech2/third_party/boost/typeof vendored Submodule

@ -0,0 +1 @@
Subproject commit 4bc9de322cd44373435540d4e6c8f207892fc9a0

@ -0,0 +1 @@
Subproject commit 5e6b9291deb55567d41416af1e77c2516dc1250f

1
speech2/third_party/boost/url vendored Submodule

@ -0,0 +1 @@
Subproject commit bbbef97a5b30cd6d11e0c0ad5994a70a136e35cb

1
speech2/third_party/boost/utility vendored Submodule

@ -0,0 +1 @@
Subproject commit e0ecf927643b13c63dfd9a38741315ea8b845135

1
speech2/third_party/boost/variant2 vendored Submodule

@ -0,0 +1 @@
Subproject commit ff36c3aa1f82d1d9a55fd006dd47cf380fc517c0

1
speech2/third_party/boost/winapi vendored Submodule

@ -0,0 +1 @@
Subproject commit 39396bd78254053f3137510478e8f956bd2b83d4