0
0
mirror of https://github.com/rkd77/elinks.git synced 2025-10-21 19:54:04 -04:00
Files
elinks/docker/djgpp/quickjs-dos.diff
2025-10-01 16:50:56 +02:00

273 lines
8.1 KiB
Diff

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)