Skip to content

Conversation

@rkd77
Copy link
Contributor

@rkd77 rkd77 commented Jan 1, 2026

I just want a library only, so changes to the library code. It is the first step.

I compiled library by these commands:

mkdir build
cd build
cmake ..
make clean
/usr/bin/i586-pc-msdosdjgpp-gcc -D_GNU_SOURCE -I/home/git/GIT/quickjs -O3 -DNDEBUG -std=gnu11 -Wall -Wextra -Wformat=2 -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-result -Wno-stringop-truncation -Wno-array-bounds -funsigned-char -MD -MT CMakeFiles/qjs.dir/cutils.c.o -MF CMakeFiles/qjs.dir/cutils.c.o.d -o CMakeFiles/qjs.dir/cutils.c.o -c /home/git/GIT/quickjs/cutils.c

/usr/bin/i586-pc-msdosdjgpp-gcc -D_GNU_SOURCE -I/home/git/GIT/quickjs -O3 -DNDEBUG -std=gnu11 -Wall -Wextra -Wformat=2 -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-result -Wno-stringop-truncation -Wno-array-bounds -funsigned-char -MD -MT CMakeFiles/qjs.dir/dtoa.c.o -MF CMakeFiles/qjs.dir/dtoa.c.o.d -o CMakeFiles/qjs.dir/dtoa.c.o -c /home/git/GIT/quickjs/dtoa.c

/usr/bin/i586-pc-msdosdjgpp-gcc -D_GNU_SOURCE -I/home/git/GIT/quickjs -O3 -DNDEBUG -std=gnu11 -Wall -Wextra -Wformat=2 -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-result -Wno-stringop-truncation -Wno-array-bounds -funsigned-char -MD -MT CMakeFiles/qjs.dir/libregexp.c.o -MF CMakeFiles/qjs.dir/libregexp.c.o.d -o CMakeFiles/qjs.dir/libregexp.c.o -c /home/git/GIT/quickjs/libregexp.c

/usr/bin/i586-pc-msdosdjgpp-gcc -D_GNU_SOURCE -I/home/git/GIT/quickjs -O3 -DNDEBUG -std=gnu11 -Wall -Wextra -Wformat=2 -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-result -Wno-stringop-truncation -Wno-array-bounds -funsigned-char -MD -MT CMakeFiles/qjs.dir/libunicode.c.o -MF CMakeFiles/qjs.dir/libunicode.c.o.d -o CMakeFiles/qjs.dir/libunicode.c.o -c /home/git/GIT/quickjs/libunicode.c

/usr/bin/i586-pc-msdosdjgpp-gcc -D_GNU_SOURCE -I/home/git/GIT/quickjs -O3 -DNDEBUG -std=gnu11 -Wall -Wextra -Wformat=2 -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-result -Wno-stringop-truncation -Wno-array-bounds -funsigned-char -MD -MT CMakeFiles/qjs.dir/quickjs.c.o -MF CMakeFiles/qjs.dir/quickjs.c.o.d -o CMakeFiles/qjs.dir/quickjs.c.o -c /home/git/GIT/quickjs/quickjs.c

/usr/bin/i586-pc-msdosdjgpp-ar qc libqjs.a CMakeFiles/qjs.dir/cutils.c.o CMakeFiles/qjs.dir/dtoa.c.o CMakeFiles/qjs.dir/libregexp.c.o CMakeFiles/qjs.dir/libunicode.c.o CMakeFiles/qjs.dir/quickjs.c.o

/usr/bin/ranlib libqjs.a

@saghul
Copy link
Contributor

saghul commented Jan 1, 2026

LGTM. @bnoordhuis thoughts?

@rkd77 is it possible to add a CI build check for this?

Copy link
Contributor

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with djgpp support but this needs some work. Question: does djgpp not have <fenv.h>? Seems inconceivable, it's a standard header.

Apropos fmin and fmax, if they really don't exist in djgpp's libm, then we might as well open-code them in quickjs.c. We use them in only one place.

quickjs.c Outdated
}

#undef NAN
#define NAN (0.0f / 0.0f)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define NAN (0.0f / 0.0f)
#define NAN (0.0 / 0.0)

(should be double, not float)

@rkd77
Copy link
Contributor Author

rkd77 commented Jan 2, 2026

djgpp is available in version 12.2.0, and there is no fenv.h there. At least I have not found it.
INFINITY is not constant expression and fmin and fmax are not visible in libm.a.

bnoordhuis added a commit to bnoordhuis/quickjs that referenced this pull request Jan 2, 2026
It was reported that DJGPP lacks fmin and fmax. The surrounding code
code already takes care of NaNs and signed zeros, so there is no real
need to call out to said functions.

Refs: quickjs-ng#1287
@bnoordhuis
Copy link
Contributor

I've opened #1290 to remove use of fmin/fmax, they're not actually needed.

INFINITY is not constant expression

Does #1276 address that? I opened that for msvc because it has the same quirk but if it kills two birds with one stone, so much the better.

@rkd77
Copy link
Contributor Author

rkd77 commented Jan 2, 2026

When added #1276 compiles fine on crossdjgpp.

bnoordhuis added a commit that referenced this pull request Jan 4, 2026
It was reported that DJGPP lacks fmin and fmax. The surrounding code
code already takes care of NaNs and signed zeros, so there is no need
to call out to said functions.

Refs: #1287
@bnoordhuis
Copy link
Contributor

@rkd77 with those two prs merged, can you rebase/update this pr? Thanks.

I just want a library only, so changes to the library code.
It is the first step.

I compiled library by these commands:

mkdir build
cd build
cmake ..
make clean
/usr/bin/i586-pc-msdosdjgpp-gcc -D_GNU_SOURCE -I/home/git/GIT/quickjs -O3 -DNDEBUG -std=gnu11 -Wall -Wextra -Wformat=2 -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-result -Wno-stringop-truncation -Wno-array-bounds -funsigned-char -MD -MT CMakeFiles/qjs.dir/cutils.c.o -MF CMakeFiles/qjs.dir/cutils.c.o.d -o CMakeFiles/qjs.dir/cutils.c.o -c /home/git/GIT/quickjs/cutils.c
/usr/bin/i586-pc-msdosdjgpp-gcc -D_GNU_SOURCE -I/home/git/GIT/quickjs -O3 -DNDEBUG -std=gnu11 -Wall -Wextra -Wformat=2 -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-result -Wno-stringop-truncation -Wno-array-bounds -funsigned-char -MD -MT CMakeFiles/qjs.dir/dtoa.c.o -MF CMakeFiles/qjs.dir/dtoa.c.o.d -o CMakeFiles/qjs.dir/dtoa.c.o -c /home/git/GIT/quickjs/dtoa.c
/usr/bin/i586-pc-msdosdjgpp-gcc -D_GNU_SOURCE -I/home/git/GIT/quickjs -O3 -DNDEBUG -std=gnu11 -Wall -Wextra -Wformat=2 -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-result -Wno-stringop-truncation -Wno-array-bounds -funsigned-char -MD -MT CMakeFiles/qjs.dir/libregexp.c.o -MF CMakeFiles/qjs.dir/libregexp.c.o.d -o CMakeFiles/qjs.dir/libregexp.c.o -c /home/git/GIT/quickjs/libregexp.c
/usr/bin/i586-pc-msdosdjgpp-gcc -D_GNU_SOURCE -I/home/git/GIT/quickjs -O3 -DNDEBUG -std=gnu11 -Wall -Wextra -Wformat=2 -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-result -Wno-stringop-truncation -Wno-array-bounds -funsigned-char -MD -MT CMakeFiles/qjs.dir/libunicode.c.o -MF CMakeFiles/qjs.dir/libunicode.c.o.d -o CMakeFiles/qjs.dir/libunicode.c.o -c /home/git/GIT/quickjs/libunicode.c
/usr/bin/i586-pc-msdosdjgpp-gcc -D_GNU_SOURCE -I/home/git/GIT/quickjs -O3 -DNDEBUG -std=gnu11 -Wall -Wextra -Wformat=2 -Wno-implicit-fallthrough -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-result -Wno-stringop-truncation -Wno-array-bounds -funsigned-char -MD -MT CMakeFiles/qjs.dir/quickjs.c.o -MF CMakeFiles/qjs.dir/quickjs.c.o.d -o CMakeFiles/qjs.dir/quickjs.c.o -c /home/git/GIT/quickjs/quickjs.c
/usr/bin/i586-pc-msdosdjgpp-ar qc libqjs.a CMakeFiles/qjs.dir/cutils.c.o CMakeFiles/qjs.dir/dtoa.c.o CMakeFiles/qjs.dir/libregexp.c.o CMakeFiles/qjs.dir/libunicode.c.o CMakeFiles/qjs.dir/quickjs.c.o
/usr/bin/ranlib libqjs.a
@rkd77 rkd77 reopened this Jan 4, 2026
@rkd77
Copy link
Contributor Author

rkd77 commented Jan 4, 2026

I'm not too familiar with git, the patch recreated.

Copy link
Contributor

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with two final flourishes.

quickjs.c Outdated
Comment on lines 43 to 45
#ifndef __DJGPP
#include <fenv.h>
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the header can simply be removed, I don't think there's anything still using it. Neither was there before I removed fmin/fmax, those live in math.h.

Suggested change
#ifndef __DJGPP
#include <fenv.h>
#endif

no need for cast

Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
@rkd77
Copy link
Contributor Author

rkd77 commented Jan 4, 2026

Added two commits.

@saghul saghul merged commit 1fbdeab into quickjs-ng:master Jan 4, 2026
122 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants