Skip to content

Commit 9de1526

Browse files
authored
Add NetBSD support (#177)
1 parent 7542b14 commit 9de1526

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,18 @@ jobs:
403403
run: |
404404
gmake
405405
gmake stats
406+
407+
netbsd:
408+
runs-on: ubuntu-latest
409+
steps:
410+
- uses: actions/checkout@v3
411+
- name: build + test
412+
uses: vmactions/netbsd-vm@v1
413+
with:
414+
usesh: true
415+
prepare: |
416+
/usr/sbin/pkg_add cmake gmake
417+
run: |
418+
gmake
419+
gmake stats
420+
gmake test

cutils.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,22 @@ static inline void put_u8(uint8_t *tab, uint8_t val)
225225
*tab = val;
226226
}
227227

228+
#ifndef bswap16
228229
static inline uint16_t bswap16(uint16_t x)
229230
{
230231
return (x >> 8) | (x << 8);
231232
}
233+
#endif
232234

235+
#ifndef bswap32
233236
static inline uint32_t bswap32(uint32_t v)
234237
{
235238
return ((v & 0xff000000) >> 24) | ((v & 0x00ff0000) >> 8) |
236239
((v & 0x0000ff00) << 8) | ((v & 0x000000ff) << 24);
237240
}
241+
#endif
238242

243+
#ifndef bswap64
239244
static inline uint64_t bswap64(uint64_t v)
240245
{
241246
return ((v & ((uint64_t)0xff << (7 * 8))) >> (7 * 8)) |
@@ -247,6 +252,7 @@ static inline uint64_t bswap64(uint64_t v)
247252
((v & ((uint64_t)0xff << (1 * 8))) << (5 * 8)) |
248253
((v & ((uint64_t)0xff << (0 * 8))) << (7 * 8));
249254
}
255+
#endif
250256

251257
static inline void inplace_bswap16(uint8_t *tab) {
252258
put_u16(tab, bswap16(get_u16(tab)));

libunicode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,8 +947,8 @@ int unicode_script(CharRange *cr,
947947
int script_idx;
948948
const uint8_t *p, *p_end;
949949
uint32_t c, c1, b, n, v, v_len, i, type;
950-
CharRange cr1_s, *cr1;
951-
CharRange cr2_s, *cr2 = &cr2_s;
950+
CharRange cr1_s = { 0 }, *cr1 = NULL;
951+
CharRange cr2_s = { 0 }, *cr2 = &cr2_s;
952952
BOOL is_common;
953953

954954
script_idx = unicode_find_name(unicode_script_name_table, script_name);

quickjs-libc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ typedef sig_t sighandler_t;
7171
#define environ (*_NSGetEnviron())
7272
#endif
7373

74-
#if defined(__OpenBSD__) || defined(__FreeBSD__)
74+
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
7575
typedef sig_t sighandler_t;
7676
extern char **environ;
7777
#endif
@@ -3589,6 +3589,8 @@ void js_std_set_worker_new_context_func(JSContext *(*func)(JSRuntime *rt))
35893589
#define OS_PLATFORM "linux"
35903590
#elif defined(__OpenBSD__)
35913591
#define OS_PLATFORM "openbsd"
3592+
#elif defined(__NetBSD__)
3593+
#define OS_PLATFORM "netbsd"
35923594
#elif defined(__FreeBSD__)
35933595
#define OS_PLATFORM "freebsd"
35943596
#else

0 commit comments

Comments
 (0)