Skip to content

Commit 2edab4f

Browse files
committed
fix: use size_t/uintptr_t sized variable for exposetype so BigInt isn't used on wasm32
1 parent 932880e commit 2edab4f

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

App-MHFS/share/public_html/static/music_worklet_inprogress/decoder/src/exposetype.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
// ExposeType: Expose constants, structs, and unions to js
22
#pragma once
33
#include <stddef.h>
4+
#include <stdint.h>
45
#include <assert.h>
56

7+
#if defined(__SIZEOF_SIZE_T__) && defined(__SIZEOF_POINTER__)
8+
#if __SIZEOF_SIZE_T__ >= __SIZEOF_POINTER__
9+
typedef size_t et_value;
10+
#else
11+
typedef uintptr_t et_value;
12+
#endif
13+
#else
14+
typedef size_t et_value;
15+
static_assert(sizeof(et_value) < sizeof(uintptr_t), "et_value not big enough for pointer");
16+
#endif
17+
618
typedef enum {
719
ET_TT_CONST_IV = 1,
820
ET_TT_CONST_CSTRING = 2,
@@ -21,7 +33,7 @@ case 0: \
2133
return XTYPE; \
2234
break; \
2335
case 1: \
24-
return (uint64_t)#X; \
36+
return (et_value)#X; \
2537
break; \
2638
case 2: \
2739
return X; \
@@ -39,7 +51,7 @@ case 0: \
3951
return XTYPE; \
4052
break; \
4153
case 1: \
42-
return (uint64_t)#XMEMBER; \
54+
return (et_value)#XMEMBER; \
4355
break; \
4456
case 2: \
4557
return offsetof(XSTRUCT, XMEMBER); \
@@ -72,7 +84,7 @@ case 0: \
7284
return ET_TT_ST; \
7385
break; \
7486
case 1: \
75-
return (uint64_t)#X; \
87+
return (et_value)#X; \
7688
break; \
7789
case 2: \
7890
return sizeof(X); \

App-MHFS/share/public_html/static/music_worklet_inprogress/decoder/src/mhfs_cl_misc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
#endif
1010
#include <stdint.h>
1111
#include <stddef.h>
12+
#include "exposetype.h"
1213

1314
// util
1415
LIBEXPORT unsigned long mhfs_cl_djb2(const uint8_t *pData, const size_t dataLen);
1516

1617
// For JS convenience export types
17-
LIBEXPORT uint64_t mhfs_cl_et_load_type(const uint32_t itemIndex, const uint32_t subItemIndex);
18+
LIBEXPORT et_value mhfs_cl_et_load_type(const uint32_t itemIndex, const uint32_t subItemIndex);
1819
#endif /* mhfs_cl_misc_h */
1920

2021
#if defined(MHFSCLMISC_IMPLEMENTATION)
2122
#ifndef mhfs_cl_misc_c
2223
#define mhfs_cl_misc_c
2324

24-
#include "exposetype.h"
2525
#include "mhfs_cl.h"
2626
#include "mhfs_cl_track.h"
2727

@@ -35,7 +35,7 @@ unsigned long mhfs_cl_djb2(const uint8_t *pData, const size_t dataLen)
3535
return hash;
3636
}
3737

38-
uint64_t mhfs_cl_et_load_type(const uint32_t itemIndex, const uint32_t subItemIndex)
38+
et_value mhfs_cl_et_load_type(const uint32_t itemIndex, const uint32_t subItemIndex)
3939
{
4040
switch(itemIndex)
4141
{

0 commit comments

Comments
 (0)