@bash0816/copilot-termux 1.0.82 → 1.0.88

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.
@@ -1,85 +0,0 @@
1
- /*
2
- * bionic-compat.so: provides glibc/musl symbols missing from Android bionic,
3
- * so that linuxmusl-arm64/runtime.node can be dlopen'd on Termux.
4
- * Load as LD_PRELOAD before Node.js.
5
- */
6
- #define _GNU_SOURCE
7
- #include <string.h>
8
- #include <stdlib.h>
9
- #include <errno.h>
10
- #include <spawn.h>
11
- #include <stddef.h>
12
- #include <unistd.h>
13
- #include <dlfcn.h>
14
- #include <math.h>
15
-
16
- /* bionic exports __errno() instead of __errno_location() */
17
- extern int *__errno(void);
18
- int *__errno_location(void) { return __errno(); }
19
-
20
- int bcmp(const void *s1, const void *s2, size_t n) { return memcmp(s1, s2, n); }
21
-
22
- /* jemalloc sized dealloc - bionic uses scudo, delegate to free */
23
- void sdallocx(void *ptr, size_t size, int flags) {
24
- (void)size; (void)flags;
25
- free(ptr);
26
- }
27
-
28
- /* XSI strerror_r (int-returning); bionic's strerror_r returns char* */
29
- int __xpg_strerror_r(int errnum, char *buf, size_t buflen) {
30
- const char *s = strerror(errnum);
31
- if (!s) { *__errno() = EINVAL; return EINVAL; }
32
- size_t len = strlen(s);
33
- if (len >= buflen) { *__errno() = ERANGE; return ERANGE; }
34
- memcpy(buf, s, len + 1);
35
- return 0;
36
- }
37
-
38
- /* pidfd APIs absent from this Android kernel version */
39
- int pidfd_getpid(int fd) { (void)fd; *__errno() = ENOSYS; return -1; }
40
-
41
- int pidfd_spawnp(int *pidfd,
42
- const char *path,
43
- const posix_spawn_file_actions_t *fa,
44
- const posix_spawnattr_t *attr,
45
- char *const argv[],
46
- char *const envp[]) {
47
- (void)pidfd; (void)path; (void)fa; (void)attr; (void)argv; (void)envp;
48
- *__errno() = ENOSYS;
49
- return -1;
50
- }
51
-
52
- /* musl bundles math in libc.so; bionic splits to libm.so.
53
- * Since we are LD_PRELOAD, RTLD_NEXT finds the real libm.so symbols. */
54
- typedef double (*fn_dd)(double);
55
- typedef double (*fn_ddd)(double, double);
56
- typedef float (*fn_ff)(float);
57
-
58
- static fn_ddd _pow;
59
- static fn_dd _log;
60
- static fn_dd _log2;
61
- static fn_dd _exp2;
62
- static fn_ff _expf;
63
- static fn_ff _log10f;
64
- static fn_ff _sinf;
65
-
66
- __attribute__((constructor))
67
- static void compat_init(void) {
68
- _pow = (fn_ddd)dlsym(RTLD_NEXT, "pow");
69
- _log = (fn_dd) dlsym(RTLD_NEXT, "log");
70
- _log2 = (fn_dd) dlsym(RTLD_NEXT, "log2");
71
- _exp2 = (fn_dd) dlsym(RTLD_NEXT, "exp2");
72
- _expf = (fn_ff) dlsym(RTLD_NEXT, "expf");
73
- _log10f = (fn_ff) dlsym(RTLD_NEXT, "log10f");
74
- _sinf = (fn_ff) dlsym(RTLD_NEXT, "sinf");
75
- /* NULL is expected in non-node processes (shells) that inherit LD_PRELOAD
76
- * but do not link libm.so. Those processes never invoke math stubs. */
77
- }
78
-
79
- double pow(double x, double y) { if (!_pow) abort(); return _pow(x, y); }
80
- double log(double x) { if (!_log) abort(); return _log(x); }
81
- double log2(double x) { if (!_log2) abort(); return _log2(x); }
82
- double exp2(double x) { if (!_exp2) abort(); return _exp2(x); }
83
- float expf(float x) { if (!_expf) abort(); return _expf(x); }
84
- float log10f(float x) { if (!_log10f) abort(); return _log10f(x); }
85
- float sinf(float x) { if (!_sinf) abort(); return _sinf(x); }