Skip to content

Commit f8f802e

Browse files
committed
illumos build fix
1 parent 1d47486 commit f8f802e

7 files changed

Lines changed: 41 additions & 3 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ else()
3232
set(WATCHOS FALSE)
3333
endif()
3434

35+
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
36+
set(SUNOS TRUE)
37+
else()
38+
set(SUNOS FALSE)
39+
endif()
40+
3541
if(NOT CMAKE_BUILD_TYPE)
3642
message(STATUS "No build type selected, default to Release")
3743
set(CMAKE_BUILD_TYPE "Release")
@@ -62,7 +68,9 @@ xcheck_add_c_compiler_flag(-Wno-unused-but-set-variable)
6268
xcheck_add_c_compiler_flag(-Wno-unused-result)
6369
xcheck_add_c_compiler_flag(-Wno-stringop-truncation)
6470
xcheck_add_c_compiler_flag(-Wno-array-bounds)
71+
if(NOT SUNOS)
6572
xcheck_add_c_compiler_flag(-funsigned-char)
73+
endif()
6674

6775
# ClangCL is command line compatible with MSVC, so 'MSVC' is set.
6876
if(MSVC)

‎cutils.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ extern "C" {
5959
#include <unistd.h>
6060
#endif
6161

62+
#if defined(__sun)
63+
#undef __maybe_unused
64+
#endif
65+
6266
#if defined(_MSC_VER) && !defined(__clang__)
6367
# define likely(x) (x)
6468
# define unlikely(x) (x)

‎libregexp.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
#include "cutils.h"
3232
#include "libregexp.h"
3333

34+
#if defined(__sun)
35+
#include <alloca.h>
36+
#endif
37+
3438
/*
3539
TODO:
3640

‎meson.build‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ qjs_gcc_warning_args = [
3333
'-Wno-array-bounds',
3434
'-Wno-format-truncation',
3535
]
36-
qjs_gcc_args = [
37-
'-funsigned-char',
38-
]
36+
qjs_gcc_args = []
37+
38+
if host_system != 'sunos'
39+
qjs_gcc_args += '-funsigned-char'
40+
endif
3941

4042
if host_system == 'darwin'
4143
# https://github.com/quickjs-ng/quickjs/issues/453

‎quickjs-libc.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ typedef sig_t sighandler_t;
7373
#define environ (*_NSGetEnviron())
7474
#endif
7575

76+
#ifdef __sun
77+
typedef void (*sighandler_t)(int);
78+
extern char **environ;
79+
#endif
80+
7681
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
7782
typedef sig_t sighandler_t;
7883
extern char **environ;

‎quickjs.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
#define NO_TM_GMTOFF
6666
#endif
6767

68+
#if defined(__sun)
69+
#include <alloca.h>
70+
#define NO_TM_GMTOFF
71+
#endif
72+
6873
// atomic_store etc. are completely busted in recent versions of tcc;
6974
// somehow the compiler forgets to load |ptr| into %rdi when calling
7075
// the __atomic_*() helpers in its lib/stdatomic.c and lib/atomic.S

‎run-test262.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#else
3939
#include <dirent.h>
4040
#include <unistd.h>
41+
#include <sys/stat.h>
4142
#endif
4243

4344
#include "cutils.h"
@@ -418,6 +419,11 @@ static void consider_test_file(const char *path, const char *name, int is_dir)
418419
while (pathlen > 0 && ispathsep(path[pathlen-1]))
419420
pathlen--;
420421
snprintf(s, sizeof(s), "%.*s/%s", (int)pathlen, path, name);
422+
#if !defined(_WIN32) && !defined(DT_DIR)
423+
struct stat st;
424+
if (is_dir < 0)
425+
is_dir = !stat(s, &st) && S_ISDIR(st.st_mode);
426+
#endif
421427
if (is_dir)
422428
find_test_files(s);
423429
else
@@ -448,7 +454,11 @@ static void find_test_files(const char *path)
448454
n = scandir(path, &ds, NULL, alphasort);
449455
for (i = 0; i < n; i++) {
450456
d = ds[i];
457+
#ifdef DT_DIR
451458
consider_test_file(path, d->d_name, d->d_type == DT_DIR);
459+
#else
460+
consider_test_file(path, d->d_name, -1);
461+
#endif
452462
free(d);
453463
}
454464
free(ds);

0 commit comments

Comments
 (0)