diff --git a/secp256k1-sys/build.rs b/secp256k1-sys/build.rs index 377c485..7347ccd 100644 --- a/secp256k1-sys/build.rs +++ b/secp256k1-sys/build.rs @@ -52,9 +52,10 @@ fn main() { #[cfg(feature = "recovery")] base_config.define("ENABLE_MODULE_RECOVERY", Some("1")); - // Header files. WASM only. + // WASM headers and size/align defines. if env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "wasm32" { - base_config.include("wasm-sysroot"); + base_config.include("wasm/wasm-sysroot") + .file("wasm/wasm.c"); } // secp256k1 diff --git a/secp256k1-sys/wasm-sysroot/stdio.h b/secp256k1-sys/wasm-sysroot/stdio.h deleted file mode 100644 index 36cc900..0000000 --- a/secp256k1-sys/wasm-sysroot/stdio.h +++ /dev/null @@ -1,17 +0,0 @@ -#include -#define alignof(type) offsetof (struct { char c; type member; }, member) - -extern const unsigned char WASM32_INT_SIZE = sizeof(int); -extern const unsigned char WASM32_INT_ALIGN = alignof(int); - -extern const unsigned char WASM32_UNSIGNED_INT_SIZE = sizeof(unsigned int); -extern const unsigned char WASM32_UNSIGNED_INT_ALIGN = alignof(unsigned int); - -extern const unsigned char WASM32_SIZE_T_SIZE = sizeof(size_t); -extern const unsigned char WASM32_SIZE_T_ALIGN = alignof(size_t); - -extern const unsigned char WASM32_UNSIGNED_CHAR_SIZE = sizeof(unsigned char); -extern const unsigned char WASM32_UNSIGNED_CHAR_ALIGN = alignof(unsigned char); - -extern const unsigned char WASM32_PTR_SIZE = sizeof(void*); -extern const unsigned char WASM32_PTR_ALIGN = alignof(void*); \ No newline at end of file diff --git a/secp256k1-sys/wasm-sysroot/stdlib.h b/secp256k1-sys/wasm/wasm-sysroot/stdio.h similarity index 100% rename from secp256k1-sys/wasm-sysroot/stdlib.h rename to secp256k1-sys/wasm/wasm-sysroot/stdio.h diff --git a/secp256k1-sys/wasm/wasm-sysroot/stdlib.h b/secp256k1-sys/wasm/wasm-sysroot/stdlib.h new file mode 100644 index 0000000..e69de29 diff --git a/secp256k1-sys/wasm-sysroot/string.h b/secp256k1-sys/wasm/wasm-sysroot/string.h similarity index 100% rename from secp256k1-sys/wasm-sysroot/string.h rename to secp256k1-sys/wasm/wasm-sysroot/string.h diff --git a/secp256k1-sys/wasm/wasm.c b/secp256k1-sys/wasm/wasm.c new file mode 100644 index 0000000..8eacae6 --- /dev/null +++ b/secp256k1-sys/wasm/wasm.c @@ -0,0 +1,17 @@ +#include +#define alignof(type) offsetof (struct { char c; type member; }, member) + +const unsigned char WASM32_INT_SIZE = sizeof(int); +const unsigned char WASM32_INT_ALIGN = alignof(int); + +const unsigned char WASM32_UNSIGNED_INT_SIZE = sizeof(unsigned int); +const unsigned char WASM32_UNSIGNED_INT_ALIGN = alignof(unsigned int); + +const unsigned char WASM32_SIZE_T_SIZE = sizeof(size_t); +const unsigned char WASM32_SIZE_T_ALIGN = alignof(size_t); + +const unsigned char WASM32_UNSIGNED_CHAR_SIZE = sizeof(unsigned char); +const unsigned char WASM32_UNSIGNED_CHAR_ALIGN = alignof(unsigned char); + +const unsigned char WASM32_PTR_SIZE = sizeof(void*); +const unsigned char WASM32_PTR_ALIGN = alignof(void*);