Skip to content

Commit f62bc5c

Browse files
Update headers from nodejs/node tag v21.0.0 (#34)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 1bf4bed commit f62bc5c

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

include/js_native_api.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#ifndef NAPI_EXTERN
2525
#ifdef _WIN32
2626
#define NAPI_EXTERN __declspec(dllexport)
27-
#elif defined(__wasm32__)
27+
#elif defined(__wasm__)
2828
#define NAPI_EXTERN \
2929
__attribute__((visibility("default"))) \
3030
__attribute__((__import_module__("napi")))
@@ -495,6 +495,7 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_add_finalizer(napi_env env,
495495

496496
#endif // NAPI_VERSION >= 5
497497

498+
498499
#if NAPI_VERSION >= 6
499500

500501
// BigInt

include/node_api.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#ifndef SRC_NODE_API_H_
22
#define SRC_NODE_API_H_
33

4-
#ifdef BUILDING_NODE_EXTENSION
4+
#if defined(BUILDING_NODE_EXTENSION) && !defined(NAPI_EXTERN)
55
#ifdef _WIN32
66
// Building native addon against node
77
#define NAPI_EXTERN __declspec(dllimport)
8-
#elif defined(__wasm32__)
8+
#elif defined(__wasm__)
99
#define NAPI_EXTERN __attribute__((__import_module__("napi")))
1010
#endif
1111
#endif
@@ -17,8 +17,13 @@ struct uv_loop_s; // Forward declaration.
1717
#ifdef _WIN32
1818
#define NAPI_MODULE_EXPORT __declspec(dllexport)
1919
#else
20+
#ifdef __EMSCRIPTEN__
21+
#define NAPI_MODULE_EXPORT \
22+
__attribute__((visibility("default"))) __attribute__((used))
23+
#else
2024
#define NAPI_MODULE_EXPORT __attribute__((visibility("default")))
2125
#endif
26+
#endif
2227

2328
#if defined(__GNUC__)
2429
#define NAPI_NO_RETURN __attribute__((noreturn))
@@ -49,7 +54,7 @@ typedef struct napi_module {
4954
NAPI_MODULE_INITIALIZER_X_HELPER(base, version)
5055
#define NAPI_MODULE_INITIALIZER_X_HELPER(base, version) base##version
5156

52-
#ifdef __wasm32__
57+
#ifdef __wasm__
5358
#define NAPI_MODULE_INITIALIZER_BASE napi_register_wasm_v
5459
#else
5560
#define NAPI_MODULE_INITIALIZER_BASE napi_register_module_v
@@ -143,7 +148,6 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_get_buffer_info(napi_env env,
143148
void** data,
144149
size_t* length);
145150

146-
#ifndef __wasm32__
147151
// Methods to manage simple async operations
148152
NAPI_EXTERN napi_status NAPI_CDECL
149153
napi_create_async_work(napi_env env,
@@ -159,7 +163,6 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_queue_async_work(napi_env env,
159163
napi_async_work work);
160164
NAPI_EXTERN napi_status NAPI_CDECL napi_cancel_async_work(napi_env env,
161165
napi_async_work work);
162-
#endif // __wasm32__
163166

164167
// version management
165168
NAPI_EXTERN napi_status NAPI_CDECL
@@ -197,7 +200,6 @@ napi_close_callback_scope(napi_env env, napi_callback_scope scope);
197200

198201
#if NAPI_VERSION >= 4
199202

200-
#ifndef __wasm32__
201203
// Calling into JS from other threads
202204
NAPI_EXTERN napi_status NAPI_CDECL
203205
napi_create_threadsafe_function(napi_env env,
@@ -231,7 +233,6 @@ napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func);
231233

232234
NAPI_EXTERN napi_status NAPI_CDECL
233235
napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func);
234-
#endif // __wasm32__
235236

236237
#endif // NAPI_VERSION >= 4
237238

0 commit comments

Comments
 (0)