pcbjam/wasm/libcontext/libcontext_wasm.h
Viktor Vaczi 3034d9d76f Add KiCad WASM build infrastructure and dependency scripts
- Add build environment setup (scripts/common/env.sh, versions.sh, functions.sh)
- Add dependency build scripts for Zstd, GLM, FreeType, HarfBuzz, Pixman, Cairo
- Add placeholder scripts for OpenCASCADE, ngspice, protobuf
- Add WASM compatibility layer (wasm/kiplatform/, wasm/libcontext/)
- Add CMake modules for KiCad WASM cross-compilation
- Add PCBnew test infrastructure (tests/kicad/)
- Add build plan documentation

Successfully tested builds: Zstd 1.5.5, GLM 0.9.9.8, FreeType 2.13.2,
HarfBuzz 8.3.0, Pixman 0.42.2, Cairo 1.18.0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 13:15:04 +01:00

52 lines
1.2 KiB
C++

/*
* WASM implementation of libcontext using Emscripten Asyncify
*
* This header provides WASM-specific definitions for the libcontext API.
* The implementation uses Emscripten's Asyncify feature to implement
* fiber-like context switching in WebAssembly.
*
* Asyncify works by:
* 1. Instrumenting the WASM code to save/restore the call stack
* 2. Allowing execution to suspend at any point
* 3. Resuming execution from where it was suspended
*
* This is used by KiCad's router for coroutine-based routing.
*/
#ifndef LIBCONTEXT_WASM_H
#define LIBCONTEXT_WASM_H
#include <cstddef>
#include <cstdint>
// Define WASM platform
#define LIBCONTEXT_PLATFORM_wasm
#define LIBCONTEXT_CALL_CONVENTION
#ifdef __cplusplus
namespace libcontext {
#endif
typedef void* fcontext_t;
#ifdef __cplusplus
extern "C" {
#endif
void LIBCONTEXT_CALL_CONVENTION release_fcontext( fcontext_t ctx );
intptr_t LIBCONTEXT_CALL_CONVENTION jump_fcontext( fcontext_t* ofc, fcontext_t nfc,
intptr_t vp, bool preserve_fpu = true );
fcontext_t LIBCONTEXT_CALL_CONVENTION make_fcontext( void* sp, size_t size,
void (* fn)( intptr_t ) );
#ifdef __cplusplus
} // extern "C"
#endif
#ifdef __cplusplus
} // namespace libcontext
#endif
#endif // LIBCONTEXT_WASM_H