Skip to content

Commit 86d95bb

Browse files
committed
Remove WASM32_* const definitions
The const definitions in `stdio.h` are causing the `wasm-pack` build to fail due to 'duplicate symbol' errors. This can be solved by just removing the definitions.
1 parent 1cf2429 commit 86d95bb

File tree

3 files changed

+0
-61
lines changed

3 files changed

+0
-61
lines changed

secp256k1-sys/src/types.rs

-38
Original file line numberDiff line numberDiff line change
@@ -66,41 +66,3 @@ mod tests {
6666
assert!(mem::align_of::<AlignedType>() >= mem::align_of::<self::libc::max_align_t>());
6767
}
6868
}
69-
70-
#[doc(hidden)]
71-
#[cfg(target_arch = "wasm32")]
72-
pub fn sanity_checks_for_wasm() {
73-
use core::mem::{align_of, size_of};
74-
extern "C" {
75-
pub static WASM32_INT_SIZE: c_uchar;
76-
pub static WASM32_INT_ALIGN: c_uchar;
77-
78-
pub static WASM32_UNSIGNED_INT_SIZE: c_uchar;
79-
pub static WASM32_UNSIGNED_INT_ALIGN: c_uchar;
80-
81-
pub static WASM32_SIZE_T_SIZE: c_uchar;
82-
pub static WASM32_SIZE_T_ALIGN: c_uchar;
83-
84-
pub static WASM32_UNSIGNED_CHAR_SIZE: c_uchar;
85-
pub static WASM32_UNSIGNED_CHAR_ALIGN: c_uchar;
86-
87-
pub static WASM32_PTR_SIZE: c_uchar;
88-
pub static WASM32_PTR_ALIGN: c_uchar;
89-
}
90-
unsafe {
91-
assert_eq!(size_of::<c_int>(), WASM32_INT_SIZE as usize);
92-
assert_eq!(align_of::<c_int>(), WASM32_INT_ALIGN as usize);
93-
94-
assert_eq!(size_of::<c_uint>(), WASM32_UNSIGNED_INT_SIZE as usize);
95-
assert_eq!(align_of::<c_uint>(), WASM32_UNSIGNED_INT_ALIGN as usize);
96-
97-
assert_eq!(size_of::<size_t>(), WASM32_SIZE_T_SIZE as usize);
98-
assert_eq!(align_of::<size_t>(), WASM32_SIZE_T_ALIGN as usize);
99-
100-
assert_eq!(size_of::<c_uchar>(), WASM32_UNSIGNED_CHAR_SIZE as usize);
101-
assert_eq!(align_of::<c_uchar>(), WASM32_UNSIGNED_CHAR_ALIGN as usize);
102-
103-
assert_eq!(size_of::<*const ()>(), WASM32_PTR_SIZE as usize);
104-
assert_eq!(align_of::<*const ()>(), WASM32_PTR_ALIGN as usize);
105-
}
106-
}

secp256k1-sys/wasm-sysroot/stdio.h

-17
Original file line numberDiff line numberDiff line change
@@ -1,17 +0,0 @@
1-
#include <stddef.h>
2-
#define alignof(type) offsetof (struct { char c; type member; }, member)
3-
4-
extern const unsigned char WASM32_INT_SIZE = sizeof(int);
5-
extern const unsigned char WASM32_INT_ALIGN = alignof(int);
6-
7-
extern const unsigned char WASM32_UNSIGNED_INT_SIZE = sizeof(unsigned int);
8-
extern const unsigned char WASM32_UNSIGNED_INT_ALIGN = alignof(unsigned int);
9-
10-
extern const unsigned char WASM32_SIZE_T_SIZE = sizeof(size_t);
11-
extern const unsigned char WASM32_SIZE_T_ALIGN = alignof(size_t);
12-
13-
extern const unsigned char WASM32_UNSIGNED_CHAR_SIZE = sizeof(unsigned char);
14-
extern const unsigned char WASM32_UNSIGNED_CHAR_ALIGN = alignof(unsigned char);
15-
16-
extern const unsigned char WASM32_PTR_SIZE = sizeof(void*);
17-
extern const unsigned char WASM32_PTR_ALIGN = alignof(void*);

src/context.rs

-6
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,6 @@ mod alloc_only {
192192
/// ```
193193
#[allow(unused_mut)] // Unused when `rand-std` is not enabled.
194194
pub fn gen_new() -> Secp256k1<C> {
195-
#[cfg(target_arch = "wasm32")]
196-
ffi::types::sanity_checks_for_wasm();
197-
198195
let size = unsafe { ffi::secp256k1_context_preallocated_size(C::FLAGS) };
199196
let layout = alloc::Layout::from_size_align(size, ALIGN_TO).unwrap();
200197
let ptr = unsafe {alloc::alloc(layout)};
@@ -302,9 +299,6 @@ unsafe impl<'buf> Context for AllPreallocated<'buf> {
302299
impl<'buf, C: Context + 'buf> Secp256k1<C> {
303300
/// Lets you create a context with preallocated buffer in a generic manner(sign/verify/all)
304301
pub fn preallocated_gen_new(buf: &'buf mut [AlignedType]) -> Result<Secp256k1<C>, Error> {
305-
#[cfg(target_arch = "wasm32")]
306-
ffi::types::sanity_checks_for_wasm();
307-
308302
if buf.len() < Self::preallocate_size_gen() {
309303
return Err(Error::NotEnoughMemory);
310304
}

0 commit comments

Comments
 (0)