summaryrefslogtreecommitdiff
path: root/tests/testdata/compile/napi/module.c
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2024-07-23 01:42:26 +0100
committerGitHub <noreply@github.com>2024-07-23 02:42:26 +0200
commit8a7ed17ea29a5cc3f1fbf46cc848e3dad5b72f89 (patch)
tree28aa9ef2254738841de77b788001c9400a4004cb /tests/testdata/compile/napi/module.c
parent3f8efe5289d88097ab49e7a8fcda763c2823376b (diff)
Revert "fix(cli): add NAPI support in standalone mode (#24642)" (#24682)
This reverts commit 4e8f5875bc59ddfb84c8b0b26071a547b49823a9. Reverting because, it caused a failure during v1.45.3 publish: https://github.com/denoland/deno/actions/runs/10048730693/job/27773718095 CC @Mutefish0
Diffstat (limited to 'tests/testdata/compile/napi/module.c')
-rw-r--r--tests/testdata/compile/napi/module.c68
1 files changed, 0 insertions, 68 deletions
diff --git a/tests/testdata/compile/napi/module.c b/tests/testdata/compile/napi/module.c
deleted file mode 100644
index 4548aa37f..000000000
--- a/tests/testdata/compile/napi/module.c
+++ /dev/null
@@ -1,68 +0,0 @@
-typedef struct napi_module {
- int nm_version;
- unsigned int nm_flags;
- const char* nm_filename;
- void* nm_register_func;
- const char* nm_modname;
- void* nm_priv;
- void* reserved[4];
-} napi_module;
-
-#ifdef _WIN32
-#define NAPI_EXTERN __declspec(dllexport)
-#define NAPI_CDECL __cdecl
-#else
-#define NAPI_EXTERN __attribute__((visibility("default")))
-#define NAPI_CDECL
-#endif
-
-NAPI_EXTERN void NAPI_CDECL
-napi_module_register(napi_module* mod);
-
-#if defined(_MSC_VER)
-#if defined(__cplusplus)
-#define NAPI_C_CTOR(fn) \
- static void NAPI_CDECL fn(void); \
- namespace { \
- struct fn##_ { \
- fn##_() { fn(); } \
- } fn##_v_; \
- } \
- static void NAPI_CDECL fn(void)
-#else // !defined(__cplusplus)
-#pragma section(".CRT$XCU", read)
-// The NAPI_C_CTOR macro defines a function fn that is called during CRT
-// initialization.
-// C does not support dynamic initialization of static variables and this code
-// simulates C++ behavior. Exporting the function pointer prevents it from being
-// optimized. See for details:
-// https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-initialization?view=msvc-170
-#define NAPI_C_CTOR(fn) \
- static void NAPI_CDECL fn(void); \
- __declspec(dllexport, allocate(".CRT$XCU")) void(NAPI_CDECL * fn##_)(void) = \
- fn; \
- static void NAPI_CDECL fn(void)
-#endif // defined(__cplusplus)
-#else
-#define NAPI_C_CTOR(fn) \
- static void fn(void) __attribute__((constructor)); \
- static void fn(void)
-#endif
-
-#define NAPI_MODULE_TEST(modname, regfunc) \
- static napi_module _module = { \
- 1, \
- 0, \
- __FILE__, \
- regfunc, \
- #modname, \
- 0, \
- {0}, \
- }; \
- NAPI_C_CTOR(_register_##modname) { napi_module_register(&_module); } \
-
-void* init(void* env __attribute__((unused)), void* exports) {
- return exports;
-}
-
-NAPI_MODULE_TEST(TEST_NAPI_MODULE_NAME, init)