vsql-node 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +203 -2
- package/binding.gyp +61 -0
- package/index.d.ts +133 -0
- package/internal/amalgamation/LICENSE +21 -0
- package/internal/amalgamation/LICENSE-V +21 -0
- package/internal/amalgamation/afunix.h +26 -0
- package/internal/amalgamation/atomic.h +571 -0
- package/internal/amalgamation/core_windows.c +25 -0
- package/internal/amalgamation/core_windows.h +9 -0
- package/internal/amalgamation/execute_capture_nix.c +7 -0
- package/internal/amalgamation/execute_capture_nix.h +266 -0
- package/internal/amalgamation/gc/cord.h +426 -0
- package/internal/amalgamation/gc/cord_pos.h +151 -0
- package/internal/amalgamation/gc/ec.h +91 -0
- package/internal/amalgamation/gc/gc.h +2826 -0
- package/internal/amalgamation/gc/gc_allocator.h +480 -0
- package/internal/amalgamation/gc/gc_backptr.h +109 -0
- package/internal/amalgamation/gc/gc_config_macros.h +548 -0
- package/internal/amalgamation/gc/gc_disclaim.h +85 -0
- package/internal/amalgamation/gc/gc_gcj.h +123 -0
- package/internal/amalgamation/gc/gc_inline.h +261 -0
- package/internal/amalgamation/gc/gc_mark.h +516 -0
- package/internal/amalgamation/gc/gc_pthread_redirects.h +140 -0
- package/internal/amalgamation/gc/gc_tiny_fl.h +107 -0
- package/internal/amalgamation/gc/gc_typed.h +196 -0
- package/internal/amalgamation/gc/gc_version.h +55 -0
- package/internal/amalgamation/gc/javaxfc.h +76 -0
- package/internal/amalgamation/gc/leak_detector.h +120 -0
- package/internal/amalgamation/gc.c +45932 -0
- package/internal/amalgamation/gc.h +4 -0
- package/internal/amalgamation/gc_boehm_helpers.c +64 -0
- package/internal/amalgamation/gc_debugger_linux.h +61 -0
- package/internal/amalgamation/getrandom_linux.h +33 -0
- package/internal/amalgamation/ipv6_v6only.h +5 -0
- package/internal/amalgamation/libvsql.c +27 -0
- package/internal/amalgamation/libvsql.h +1772 -0
- package/internal/amalgamation/libvsql_linux_amd64.c +106591 -0
- package/internal/amalgamation/libvsql_linux_arm64.c +106571 -0
- package/internal/amalgamation/libvsql_macos_amd64.c +106728 -0
- package/internal/amalgamation/libvsql_macos_arm64.c +106708 -0
- package/internal/amalgamation/libvsql_windows_amd64.c +108235 -0
- package/internal/amalgamation/segfault_handler_nix.c +56 -0
- package/internal/amalgamation/segfault_handler_nix.h +449 -0
- package/internal/amalgamation/segfault_handler_windows.h +52 -0
- package/internal/amalgamation/thread_helper.c +12 -0
- package/internal/amalgamation/thread_helper.h +96 -0
- package/internal/amalgamation/ticks_windows.c +3 -0
- package/internal/amalgamation/ticks_windows.h +31 -0
- package/internal/amalgamation/ticks_windows_api.h +6 -0
- package/internal/amalgamation/vsql_runtime.c +14 -0
- package/internal/amalgamation/vsql_runtime_linux.c +6 -0
- package/internal/amalgamation/vsql_runtime_macos.c +6 -0
- package/internal/amalgamation/vsql_runtime_windows.c +6 -0
- package/lib/binding.js +13 -0
- package/lib/connection.js +492 -0
- package/lib/convert.js +213 -0
- package/lib/errors.js +17 -0
- package/lib/index.js +41 -0
- package/libvsql_flags.gypi +30 -0
- package/package.json +45 -4
- package/prebuilds/darwin-arm64/vsql-node.glibc.node +0 -0
- package/prebuilds/darwin-x64/vsql-node.glibc.node +0 -0
- package/prebuilds/linux-arm64/vsql-node.glibc.node +0 -0
- package/prebuilds/linux-x64/vsql-node.glibc.node +0 -0
- package/prebuilds/win32-x64/vsql-node.glibc.node +0 -0
- package/src/binding.c +773 -0
- package/src/runtime.c +20 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Boehm's macros and callback casts belong in a cached native object.
|
|
2
|
+
// macOS TinyCC defines __APPLE__ without __MACH__; select Boehm's Darwin configuration.
|
|
3
|
+
#if defined(__APPLE__) && !defined(GC_DARWIN_THREADS)
|
|
4
|
+
#define GC_DARWIN_THREADS 1
|
|
5
|
+
#endif
|
|
6
|
+
#if defined(__TINYC__) && defined(__linux__)
|
|
7
|
+
#include <gc/gc.h>
|
|
8
|
+
#else
|
|
9
|
+
#include <gc.h>
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
void* v_gc_malloc(size_t size) { return GC_MALLOC(size); }
|
|
13
|
+
void* v_gc_malloc_atomic(size_t size) { return GC_MALLOC_ATOMIC(size); }
|
|
14
|
+
void* v_gc_malloc_uncollectable(size_t size) { return GC_MALLOC_UNCOLLECTABLE(size); }
|
|
15
|
+
void* v_gc_realloc(void* ptr, size_t size) { return GC_REALLOC(ptr, size); }
|
|
16
|
+
void v_gc_free(void* ptr) { GC_FREE(ptr); }
|
|
17
|
+
void v_gc_init(void) { GC_INIT(); }
|
|
18
|
+
void v_gc_register_displacement(size_t offset) { GC_REGISTER_DISPLACEMENT(offset); }
|
|
19
|
+
void v_gc_set_warn_proc(GC_warn_proc cb) { GC_set_warn_proc(cb); }
|
|
20
|
+
void* v_gc_get_warn_proc(void) { return (void*)GC_get_warn_proc(); }
|
|
21
|
+
void v_gc_set_abort_func(GC_abort_func cb) { GC_set_abort_func(cb); }
|
|
22
|
+
void* v_gc_get_abort_func(void) { return (void*)GC_get_abort_func(); }
|
|
23
|
+
void v_gc_call_abort_func(void* cb, const char* msg) { ((GC_abort_func)cb)(msg); }
|
|
24
|
+
|
|
25
|
+
#if defined(GC_PTHREADS)
|
|
26
|
+
#include <pthread.h>
|
|
27
|
+
#include <signal.h>
|
|
28
|
+
#include <dlfcn.h>
|
|
29
|
+
|
|
30
|
+
// Preserve the collector's redirects when generated C uses bodyless bindings.
|
|
31
|
+
int v_gc_pthread_create(void* thread, void* attr, void* start, void* arg) {
|
|
32
|
+
return pthread_create((pthread_t*)thread, (const pthread_attr_t*)attr,
|
|
33
|
+
(void* (*)(void*))start, arg);
|
|
34
|
+
}
|
|
35
|
+
int v_gc_pthread_join(void* thread, void* retval) {
|
|
36
|
+
return pthread_join((pthread_t)thread, (void**)retval);
|
|
37
|
+
}
|
|
38
|
+
int v_gc_pthread_detach(void* thread) { return pthread_detach((pthread_t)thread); }
|
|
39
|
+
int v_gc_pthread_sigmask(int how, const void* set, void* oldset) {
|
|
40
|
+
return pthread_sigmask(how, (const sigset_t*)set, (sigset_t*)oldset);
|
|
41
|
+
}
|
|
42
|
+
// Android does not implement POSIX thread cancellation.
|
|
43
|
+
#if !defined(__ANDROID__)
|
|
44
|
+
int v_gc_pthread_cancel(void* thread) { return pthread_cancel((pthread_t)thread); }
|
|
45
|
+
#endif
|
|
46
|
+
void v_gc_pthread_exit(void* result) { pthread_exit(result); }
|
|
47
|
+
void* v_gc_dlopen(const char* path, int mode) { return dlopen(path, mode); }
|
|
48
|
+
#endif
|
|
49
|
+
|
|
50
|
+
#if defined(__linux__)
|
|
51
|
+
#define v__gc_can_register_main_data_roots_linux v_gc_can_register_main_data_roots_impl
|
|
52
|
+
#define v__gc_debugger_present_linux v_gc_debugger_present_impl
|
|
53
|
+
#define v__gc_register_main_data_roots_linux v_gc_register_main_data_roots_impl
|
|
54
|
+
#include "gc_debugger_linux.h"
|
|
55
|
+
#undef v__gc_can_register_main_data_roots_linux
|
|
56
|
+
#undef v__gc_debugger_present_linux
|
|
57
|
+
#undef v__gc_register_main_data_roots_linux
|
|
58
|
+
|
|
59
|
+
int v__gc_can_register_main_data_roots_linux(void) {
|
|
60
|
+
return v_gc_can_register_main_data_roots_impl();
|
|
61
|
+
}
|
|
62
|
+
int v__gc_debugger_present_linux(void) { return v_gc_debugger_present_impl(); }
|
|
63
|
+
void v__gc_register_main_data_roots_linux(void) { v_gc_register_main_data_roots_impl(); }
|
|
64
|
+
#endif
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#ifndef V_BUILTIN_GC_DEBUGGER_LINUX_H
|
|
2
|
+
#define V_BUILTIN_GC_DEBUGGER_LINUX_H
|
|
3
|
+
|
|
4
|
+
#if defined(__linux__)
|
|
5
|
+
#include <fcntl.h>
|
|
6
|
+
#include <string.h>
|
|
7
|
+
#include <unistd.h>
|
|
8
|
+
|
|
9
|
+
#if defined(__TINYC__)
|
|
10
|
+
extern int __data_start[] __attribute__((weak));
|
|
11
|
+
extern int data_start[] __attribute__((weak));
|
|
12
|
+
extern int _end[] __attribute__((weak));
|
|
13
|
+
#else
|
|
14
|
+
#pragma weak __data_start
|
|
15
|
+
#pragma weak data_start
|
|
16
|
+
#pragma weak _end
|
|
17
|
+
|
|
18
|
+
extern int __data_start[];
|
|
19
|
+
extern int data_start[];
|
|
20
|
+
extern int _end[];
|
|
21
|
+
#endif
|
|
22
|
+
|
|
23
|
+
static inline int v__gc_can_register_main_data_roots_linux(void) {
|
|
24
|
+
void* data_start_ptr = __data_start != NULL ? (void*)__data_start : (void*)data_start;
|
|
25
|
+
void* data_end_ptr = (void*)_end;
|
|
26
|
+
return data_start_ptr != NULL && data_end_ptr != NULL && data_start_ptr < data_end_ptr;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static inline int v__gc_debugger_present_linux(void) {
|
|
30
|
+
int fd = open("/proc/self/status", O_RDONLY);
|
|
31
|
+
if (fd < 0) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
char buf[4096];
|
|
35
|
+
ssize_t n = read(fd, buf, sizeof(buf) - 1);
|
|
36
|
+
(void)close(fd);
|
|
37
|
+
if (n <= 0) {
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
buf[n] = '\0';
|
|
41
|
+
char* tracer_pid = strstr(buf, "TracerPid:");
|
|
42
|
+
if (tracer_pid == NULL) {
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
tracer_pid += sizeof("TracerPid:") - 1;
|
|
46
|
+
while (*tracer_pid == ' ' || *tracer_pid == '\t') {
|
|
47
|
+
++tracer_pid;
|
|
48
|
+
}
|
|
49
|
+
return *tracer_pid != '0' && *tracer_pid != '\n' && *tracer_pid != '\0';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static inline void v__gc_register_main_data_roots_linux(void) {
|
|
53
|
+
if (!v__gc_can_register_main_data_roots_linux()) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
void* data_start_ptr = __data_start != NULL ? (void*)__data_start : (void*)data_start;
|
|
57
|
+
GC_add_roots(data_start_ptr, (void*)_end);
|
|
58
|
+
}
|
|
59
|
+
#endif
|
|
60
|
+
|
|
61
|
+
#endif
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#ifndef V_CRYPTO_RAND_GETRANDOM_LINUX_H
|
|
2
|
+
#define V_CRYPTO_RAND_GETRANDOM_LINUX_H
|
|
3
|
+
|
|
4
|
+
#if defined(__linux__)
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* v_crypto_getrandom fills `buf` with `n` random bytes, like getrandom(2) with no
|
|
8
|
+
* flags. Using libc allows its platform-specific optimizations, including vDSO
|
|
9
|
+
* support where available. If the compiler cannot find <sys/random.h>, use the
|
|
10
|
+
* syscall as before. Both paths retain getrandom(2)'s return value and flags.
|
|
11
|
+
*/
|
|
12
|
+
#include <unistd.h>
|
|
13
|
+
#include <sys/syscall.h>
|
|
14
|
+
|
|
15
|
+
// Bionic's libc wrapper requires API 28; Android uses the syscall at every API level.
|
|
16
|
+
#if defined(__has_include) && !defined(__ANDROID__)
|
|
17
|
+
#if __has_include(<sys/random.h>)
|
|
18
|
+
#include <sys/random.h>
|
|
19
|
+
#define V_CRYPTO_RAND_LIBC_GETRANDOM 1
|
|
20
|
+
#endif
|
|
21
|
+
#endif
|
|
22
|
+
|
|
23
|
+
static inline long v_crypto_getrandom(void* buf, size_t n) {
|
|
24
|
+
#ifdef V_CRYPTO_RAND_LIBC_GETRANDOM
|
|
25
|
+
return (long)getrandom(buf, n, 0);
|
|
26
|
+
#else
|
|
27
|
+
return syscall(SYS_getrandom, buf, n, 0);
|
|
28
|
+
#endif
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
#endif /* __linux__ */
|
|
32
|
+
|
|
33
|
+
#endif
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// libvsql.c is libvsql, the SQL/CLI (ISO/IEC 9075-3) shared library (see libvsql.h), as C generated by V.
|
|
2
|
+
//
|
|
3
|
+
// V can generate one C file for every OS and architecture (-os cross), but
|
|
4
|
+
// that C has no garbage collector (https://github.com/vlang/v/issues/31421), so
|
|
5
|
+
// the C is generated on each OS and architecture instead. Once that's fixed,
|
|
6
|
+
// this file will be replaced by the cross platform C.
|
|
7
|
+
#if defined(__x86_64__) || defined(_M_X64)
|
|
8
|
+
#define VSQL_AMD64
|
|
9
|
+
#elif defined(__aarch64__) || defined(_M_ARM64)
|
|
10
|
+
#define VSQL_ARM64
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
#if defined(_WIN32) && defined(VSQL_AMD64)
|
|
14
|
+
#include "libvsql_windows_amd64.c"
|
|
15
|
+
#elif defined(_WIN32) && defined(VSQL_ARM64)
|
|
16
|
+
#include "libvsql_windows_arm64.c"
|
|
17
|
+
#elif defined(__APPLE__) && defined(VSQL_AMD64)
|
|
18
|
+
#include "libvsql_macos_amd64.c"
|
|
19
|
+
#elif defined(__APPLE__) && defined(VSQL_ARM64)
|
|
20
|
+
#include "libvsql_macos_arm64.c"
|
|
21
|
+
#elif defined(__linux__) && defined(VSQL_AMD64)
|
|
22
|
+
#include "libvsql_linux_amd64.c"
|
|
23
|
+
#elif defined(__linux__) && defined(VSQL_ARM64)
|
|
24
|
+
#include "libvsql_linux_arm64.c"
|
|
25
|
+
#else
|
|
26
|
+
#error "There is no generated C for this OS and architecture."
|
|
27
|
+
#endif
|