File: quickjs-dos.diff

package info (click to toggle)
elinks 0.19.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,424 kB
  • sloc: ansic: 174,653; cpp: 31,967; sh: 7,841; python: 4,039; perl: 2,183; javascript: 1,794; pascal: 1,710; makefile: 1,006; yacc: 295; lisp: 125; awk: 79; ruby: 70
file content (272 lines) | stat: -rw-r--r-- 8,256 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
diff -up quickjs-2024-01-13/qjs.c.djgpp quickjs-2024-01-13/qjs.c
--- quickjs-2024-01-13/qjs.c.djgpp	2024-08-21 13:29:26.360220594 +0000
+++ quickjs-2024-01-13/qjs.c	2024-08-21 13:12:30.671515118 +0000
@@ -146,7 +146,7 @@ static size_t js_trace_malloc_usable_siz
     return malloc_size(ptr);
 #elif defined(_WIN32)
     return _msize((void *)ptr);
-#elif defined(EMSCRIPTEN)
+#elif defined(EMSCRIPTEN) || defined(__DJGPP)
     return 0;
 #elif defined(__linux__)
     return malloc_usable_size((void *)ptr);
diff -up quickjs-2024-01-13/quickjs-libc.c.djgpp quickjs-2024-01-13/quickjs-libc.c
--- quickjs-2024-01-13/quickjs-libc.c.djgpp	2024-01-13 10:20:39.000000000 +0000
+++ quickjs-2024-01-13/quickjs-libc.c	2024-08-21 13:14:45.092458496 +0000
@@ -65,7 +65,7 @@ typedef sig_t sighandler_t;
 #endif
 
 /* enable the os.Worker API. It relies on POSIX threads */
-#define USE_WORKER
+//#define USE_WORKER
 
 #ifdef USE_WORKER
 #include <pthread.h>
@@ -691,6 +691,7 @@ static JSValue js_std_getenviron(JSConte
     obj = JS_NewObject(ctx);
     if (JS_IsException(obj))
         return JS_EXCEPTION;
+#if 0
     envp = environ;
     for(idx = 0; envp[idx] != NULL; idx++) {
         name = envp[idx];
@@ -708,6 +709,7 @@ static JSValue js_std_getenviron(JSConte
         if (ret < 0)
             goto fail;
     }
+#endif
     return obj;
  fail:
     JS_FreeValue(ctx, obj);
@@ -1918,7 +1920,7 @@ static void os_signal_handler(int sig_nu
     os_pending_signals |= ((uint64_t)1 << sig_num);
 }
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(__DJGPP)
 typedef void (*sighandler_t)(int sig_num);
 #endif
 
@@ -2525,7 +2527,7 @@ static JSValue js_os_readdir(JSContext *
     return make_obj_error(ctx, obj, err);
 }
 
-#if !defined(_WIN32)
+#if !defined(_WIN32) && !defined(__DJGPP)
 static int64_t timespec_to_ms(const struct timespec *tv)
 {
     return (int64_t)tv->tv_sec * 1000 + (tv->tv_nsec / 1000000);
@@ -2585,12 +2587,12 @@ static JSValue js_os_stat(JSContext *ctx
         JS_DefinePropertyValueStr(ctx, obj, "size",
                                   JS_NewInt64(ctx, st.st_size),
                                   JS_PROP_C_W_E);
-#if !defined(_WIN32)
+#if !defined(_WIN32) && !defined(__DJGPP)
         JS_DefinePropertyValueStr(ctx, obj, "blocks",
                                   JS_NewInt64(ctx, st.st_blocks),
                                   JS_PROP_C_W_E);
 #endif
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(__DJGPP)
         JS_DefinePropertyValueStr(ctx, obj, "atime",
                                   JS_NewInt64(ctx, (int64_t)st.st_atime * 1000),
                                   JS_PROP_C_W_E);
@@ -2677,11 +2679,11 @@ static JSValue js_os_sleep(JSContext *ct
         return JS_EXCEPTION;
     if (delay < 0)
         delay = 0;
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(__DJGPP)
     {
         if (delay > INT32_MAX)
             delay = INT32_MAX;
-        Sleep(delay);
+        usleep(delay);
         ret = 0;
     }
 #else
@@ -2897,7 +2899,7 @@ static JSValue js_os_exec(JSContext *ctx
     JSValueConst options, args = argv[0];
     JSValue val, ret_val;
     const char **exec_argv, *file = NULL, *str, *cwd = NULL;
-    char **envp = environ;
+    char **envp = NULL;//environ;
     uint32_t exec_argc, i;
     int ret, pid, status;
     BOOL block_flag = TRUE, use_path = TRUE;
@@ -3073,6 +3075,7 @@ static JSValue js_os_exec(JSContext *ctx
     for(i = 0; i < exec_argc; i++)
         JS_FreeCString(ctx, exec_argv[i]);
     js_free(ctx, exec_argv);
+#if 0
     if (envp != environ) {
         char **p;
         p = envp;
@@ -3082,6 +3085,7 @@ static JSValue js_os_exec(JSContext *ctx
         }
         js_free(ctx, envp);
     }
+#endif
     return ret_val;
  exception:
     ret_val = JS_EXCEPTION;
@@ -3677,7 +3681,7 @@ static const JSCFunctionListEntry js_os_
     OS_FLAG(SIGILL),
     OS_FLAG(SIGSEGV),
     OS_FLAG(SIGTERM),
-#if !defined(_WIN32)
+#if !defined(_WIN32) && !defined(__DJGPP)
     OS_FLAG(SIGQUIT),
     OS_FLAG(SIGPIPE),
     OS_FLAG(SIGALRM),
@@ -3706,7 +3710,7 @@ static const JSCFunctionListEntry js_os_
     OS_FLAG(S_IFDIR),
     OS_FLAG(S_IFBLK),
     OS_FLAG(S_IFREG),
-#if !defined(_WIN32)
+#if !defined(_WIN32) && !defined(__DJGPP)
     OS_FLAG(S_IFSOCK),
     OS_FLAG(S_IFLNK),
     OS_FLAG(S_ISGID),
@@ -3716,7 +3720,7 @@ static const JSCFunctionListEntry js_os_
     JS_CFUNC_DEF("utimes", 3, js_os_utimes ),
     JS_CFUNC_DEF("sleep", 1, js_os_sleep ),
     JS_CFUNC_DEF("realpath", 1, js_os_realpath ),
-#if !defined(_WIN32)
+#if !defined(_WIN32) && !defined(__DJGPP)
     JS_CFUNC_MAGIC_DEF("lstat", 1, js_os_stat, 1 ),
     JS_CFUNC_DEF("symlink", 2, js_os_symlink ),
     JS_CFUNC_DEF("readlink", 1, js_os_readlink ),
diff -up quickjs-2024-01-13/quickjs.c.djgpp quickjs-2024-01-13/quickjs.c
--- quickjs-2024-01-13/quickjs.c.djgpp	2024-01-13 10:20:39.000000000 +0000
+++ quickjs-2024-01-13/quickjs.c	2024-08-21 13:18:39.088740789 +0000
@@ -30,7 +30,7 @@
 #include <assert.h>
 #include <sys/time.h>
 #include <time.h>
-#include <fenv.h>
+//#include <fenv.h>
 #include <math.h>
 #if defined(__APPLE__)
 #include <malloc/malloc.h>
@@ -68,7 +68,7 @@
 /* define to include Atomics.* operations which depend on the OS
    threads */
 #if !defined(EMSCRIPTEN)
-#define CONFIG_ATOMICS
+//#define CONFIG_ATOMICS
 #endif
 
 #if !defined(EMSCRIPTEN)
@@ -1699,7 +1699,7 @@ static size_t js_def_malloc_usable_size(
     return malloc_size(ptr);
 #elif defined(_WIN32)
     return _msize((void *)ptr);
-#elif defined(EMSCRIPTEN)
+#elif defined(EMSCRIPTEN) || defined(__DJGPP)
     return 0;
 #elif defined(__linux__)
     return malloc_usable_size((void *)ptr);
@@ -40844,6 +40851,10 @@ static JSValue js_number_isSafeInteger(J
     return JS_NewBool(ctx, is_safe_integer(d));
 }
 
+static const double DJ_INFINITY = 1e10000f;
+#undef NAN
+#define NAN (0.0f / 0.0f)
+
 static const JSCFunctionListEntry js_number_funcs[] = {
     /* global ParseInt and parseFloat should be defined already or delayed */
     JS_ALIAS_BASE_DEF("parseInt", "parseInt", 0 ),
@@ -40855,8 +40866,8 @@ static const JSCFunctionListEntry js_num
     JS_PROP_DOUBLE_DEF("MAX_VALUE", 1.7976931348623157e+308, 0 ),
     JS_PROP_DOUBLE_DEF("MIN_VALUE", 5e-324, 0 ),
     JS_PROP_DOUBLE_DEF("NaN", NAN, 0 ),
-    JS_PROP_DOUBLE_DEF("NEGATIVE_INFINITY", -INFINITY, 0 ),
-    JS_PROP_DOUBLE_DEF("POSITIVE_INFINITY", INFINITY, 0 ),
+    JS_PROP_DOUBLE_DEF("NEGATIVE_INFINITY", -DJ_INFINITY, 0 ),
+    JS_PROP_DOUBLE_DEF("POSITIVE_INFINITY", DJ_INFINITY, 0 ),
     JS_PROP_DOUBLE_DEF("EPSILON", 2.220446049250313e-16, 0 ), /* ES6 */
     JS_PROP_DOUBLE_DEF("MAX_SAFE_INTEGER", 9007199254740991.0, 0 ), /* ES6 */
     JS_PROP_DOUBLE_DEF("MIN_SAFE_INTEGER", -9007199254740991.0, 0 ), /* ES6 */
@@ -42901,6 +42912,19 @@ void JS_AddIntrinsicStringNormalize(JSCo
 
 /* Math */
 
+static double
+fmin2(double a, double b)
+{
+    return a < b ? a : b;
+}
+
+static double
+fmax2(double a, double b)
+{
+    return a > b ? a : b;
+}
+
+
 /* precondition: a and b are not NaN */
 static double js_fmin(double a, double b)
 {
@@ -42911,7 +42935,7 @@ static double js_fmin(double a, double b
         a1.u64 |= b1.u64;
         return a1.d;
     } else {
-        return fmin(a, b);
+        return fmin2(a, b);
     }
 }
 
@@ -42925,7 +42949,7 @@ static double js_fmax(double a, double b
         a1.u64 &= b1.u64;
         return a1.d;
     } else {
-        return fmax(a, b);
+        return fmax2(a, b);
     }
 }
 
--- quickjs-2025-09-13/Makefile.orig	2025-09-18 08:25:07.000000000 +0000
+++ quickjs-2025-09-13/Makefile	2025-10-01 14:32:52.348023564 +0000
@@ -90,8 +90,8 @@
   CROSS_PREFIX?=
   EXE=.exe
 else
-  CROSS_PREFIX?=
-  EXE=
+  CROSS_PREFIX=i586-pc-msdosdjgpp-
+  EXE=.exe
 endif
 
 ifdef CONFIG_CLANG
@@ -191,7 +191,7 @@
 ifdef CONFIG_WIN32
 LDEXPORT=
 else
-LDEXPORT=-rdynamic
+LDEXPORT=
 endif
 
 ifndef CONFIG_COSMO
@@ -202,7 +202,7 @@
 endif
 endif
 
-PROGS=qjs$(EXE) qjsc$(EXE) run-test262$(EXE)
+PROGS=qjs$(EXE) qjsc$(EXE)
 
 ifneq ($(CROSS_PREFIX),)
 QJSC_CC=gcc
@@ -244,9 +244,9 @@
 QJS_OBJS=$(OBJDIR)/qjs.o $(OBJDIR)/repl.o $(QJS_LIB_OBJS)
 
 HOST_LIBS=-lm -ldl -lpthread
-LIBS=-lm -lpthread
+LIBS=-lm
 ifndef CONFIG_WIN32
-LIBS+=-ldl
+LIBS+=
 endif
 LIBS+=$(EXTRA_LIBS)