Skip to content

Commit f6f8226

Browse files
committed
add haiku ci
1 parent ef851bc commit f6f8226

7 files changed

Lines changed: 121 additions & 4 deletions

File tree

.github/workflows/haiku.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Haiku
2+
3+
on:
4+
pull_request:
5+
push:
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
concurrency:
15+
group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Haiku
16+
cancel-in-progress: true
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
submodules: true
21+
22+
- name: Tests
23+
uses: vmactions/haiku-vm@v1
24+
with:
25+
usesh: true
26+
mem: 4096
27+
copyback: false
28+
prepare: |
29+
pkgman install -y git curl unzip make bash perl
30+
run: |
31+
cd $GITHUB_WORKSPACE
32+
./configure
33+
make -j2
34+
./build/haiku/x86_64/release/demo other_test

.github/workflows/netbsd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
with:
2626
usesh: true
2727
prepare: |
28-
/usr/sbin/pkg_add curl bash git gmake
28+
/usr/sbin/pkg_add -u curl bash git gmake
2929
run: |
3030
cd $GITHUB_WORKSPACE
3131
./configure

src/demo/other/test.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,41 @@
66
/* //////////////////////////////////////////////////////////////////////////////////////
77
* main
88
*/
9+
#ifdef TB_CONFIG_MODULE_HAVE_CHARSET
10+
static tb_void_t tb_demo_utf8_case_test(tb_char_t const* input, tb_char_t const* lower_expected, tb_char_t const* upper_expected)
11+
{
12+
tb_char_t* lower = tb_strdup(input);
13+
tb_char_t* upper = tb_strdup(input);
14+
tb_bool_t lower_ok = tb_false;
15+
tb_bool_t upper_ok = tb_false;
16+
if (lower && upper)
17+
{
18+
tb_long_t lower_size = tb_charset_utf8_tolower(lower, tb_strlen(lower));
19+
tb_long_t upper_size = tb_charset_utf8_toupper(upper, tb_strlen(upper));
20+
lower_ok = (lower_size >= 0 && !tb_strcmp(lower, lower_expected));
21+
upper_ok = (upper_size >= 0 && !tb_strcmp(upper, upper_expected));
22+
}
23+
24+
if (lower_ok) tb_trace_i("utf8 lower ok: %s -> %s", input, lower);
25+
else tb_trace_i("utf8 lower failed: %s -> %s, expect: %s", input, lower? lower : "(null)", lower_expected);
26+
27+
if (upper_ok) tb_trace_i("utf8 upper ok: %s -> %s", input, upper);
28+
else tb_trace_i("utf8 upper failed: %s -> %s, expect: %s", input, upper? upper : "(null)", upper_expected);
29+
30+
if (lower) tb_free(lower);
31+
if (upper) tb_free(upper);
32+
}
33+
#endif
34+
935
tb_int_t tb_demo_other_test_main(tb_int_t argc, tb_char_t** argv)
1036
{
37+
#ifdef TB_CONFIG_MODULE_HAVE_CHARSET
38+
tb_demo_utf8_case_test("Hello", "hello", "HELLO");
39+
tb_demo_utf8_case_test("Звезда Хэнсин", "звезда хэнсин", "ЗВЕЗДА ХЭНСИН");
40+
tb_demo_utf8_case_test("Test 源文件🎆 Message", "test 源文件🎆 message", "TEST 源文件🎆 MESSAGE");
41+
#else
42+
tb_used(argc);
43+
tb_used(argv);
44+
#endif
1145
return 0;
1246
}

src/tbox/platform/posix/sched_affinity.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ tb_bool_t tb_sched_setaffinity(tb_size_t pid, tb_cpuset_ref_t cpuset)
5454
tb_bool_t ok = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, (pid_t)pid, cpuset_size(cpu_set), cpu_set) == 0;
5555
cpuset_destroy(cpu_set);
5656
return ok;
57+
#elif defined(TB_CONFIG_OS_HAIKU)
58+
tb_int_t i;
59+
cpuset_t cpu_set;
60+
CPUSET_ZERO(&cpu_set);
61+
for (i = 0; i < TB_CPUSET_SIZE; i++)
62+
{
63+
if (TB_CPUSET_ISSET(i, cpuset))
64+
CPUSET_SET(i, &cpu_set);
65+
}
66+
return sched_setaffinity((pid_t)pid, sizeof(cpuset_t), &cpu_set) == 0;
5767
#else
5868
// Linux uses cpu_set_t API
5969
tb_int_t i;
@@ -94,6 +104,21 @@ tb_bool_t tb_sched_getaffinity(tb_size_t pid, tb_cpuset_ref_t cpuset)
94104
}
95105
cpuset_destroy(cpu_set);
96106
return tb_true;
107+
#elif defined(TB_CONFIG_OS_HAIKU)
108+
cpuset_t cpu_set;
109+
CPUSET_ZERO(&cpu_set);
110+
if (sched_getaffinity((pid_t)pid, sizeof(cpuset_t), &cpu_set) != 0)
111+
return tb_false;
112+
113+
// save cpuset
114+
tb_int_t i;
115+
TB_CPUSET_ZERO(cpuset);
116+
for (i = 0; i < TB_CPUSET_SIZE; i++)
117+
{
118+
if (CPUSET_ISSET(i, &cpu_set))
119+
TB_CPUSET_SET(i, cpuset);
120+
}
121+
return tb_true;
97122
#else
98123
// Linux uses cpu_set_t API
99124
cpu_set_t cpu_set;

src/tbox/platform/posix/thread_affinity.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ tb_bool_t tb_thread_setaffinity(tb_thread_ref_t thread, tb_cpuset_ref_t cpuset)
5757
tb_bool_t ok = pthread_setaffinity_np(pthread, cpuset_size(cpu_set), cpu_set) == 0;
5858
cpuset_destroy(cpu_set);
5959
return ok;
60+
#elif defined(TB_CONFIG_OS_HAIKU)
61+
tb_int_t i;
62+
cpuset_t cpu_set;
63+
CPUSET_ZERO(&cpu_set);
64+
for (i = 0; i < TB_CPUSET_SIZE; i++)
65+
{
66+
if (TB_CPUSET_ISSET(i, cpuset))
67+
CPUSET_SET(i, &cpu_set);
68+
}
69+
return pthread_setaffinity_np(pthread, sizeof(cpuset_t), &cpu_set) == 0;
6070
#else
6171
// Linux uses cpu_set_t API
6272
tb_int_t i;
@@ -100,6 +110,21 @@ tb_bool_t tb_thread_getaffinity(tb_thread_ref_t thread, tb_cpuset_ref_t cpuset)
100110
}
101111
cpuset_destroy(cpu_set);
102112
return tb_true;
113+
#elif defined(TB_CONFIG_OS_HAIKU)
114+
cpuset_t cpu_set;
115+
CPUSET_ZERO(&cpu_set);
116+
if (pthread_getaffinity_np(pthread, sizeof(cpuset_t), &cpu_set) != 0)
117+
return tb_false;
118+
119+
// save cpuset
120+
tb_int_t i;
121+
TB_CPUSET_ZERO(cpuset);
122+
for (i = 0; i < TB_CPUSET_SIZE; i++)
123+
{
124+
if (CPUSET_ISSET(i, &cpu_set))
125+
TB_CPUSET_SET(i, cpuset);
126+
}
127+
return tb_true;
103128
#else
104129
// Linux uses cpu_set_t API
105130
cpu_set_t cpu_set;

src/tbox/platform/sched.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
# include "windows/sched_affinity.c"
3939
#elif defined(TB_CONFIG_OS_MACOSX)
4040
# include "mach/sched_affinity.c"
41-
#elif defined(TB_CONFIG_POSIX_HAVE_SCHED_SETAFFINITY)
41+
#elif defined(TB_CONFIG_POSIX_HAVE_SCHED_SETAFFINITY) && !defined(TB_CONFIG_OS_HAIKU)
4242
# include "posix/sched_affinity.c"
4343
#else
4444
tb_bool_t tb_sched_setaffinity(tb_size_t pid, tb_cpuset_ref_t cpuset)
@@ -52,4 +52,3 @@ tb_bool_t tb_sched_getaffinity(tb_size_t pid, tb_cpuset_ref_t cpuset)
5252
return tb_false;
5353
}
5454
#endif
55-

src/tbox/platform/thread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ tb_size_t tb_thread_self()
163163
# include "windows/thread_affinity.c"
164164
#elif defined(TB_CONFIG_OS_MACOSX) || defined(TB_CONFIG_OS_IOS)
165165
# include "mach/thread_affinity.c"
166-
#elif defined(TB_CONFIG_POSIX_HAVE_PTHREAD_SETAFFINITY_NP)
166+
#elif defined(TB_CONFIG_POSIX_HAVE_PTHREAD_SETAFFINITY_NP) && !defined(TB_CONFIG_OS_HAIKU)
167167
# include "posix/thread_affinity.c"
168168
#else
169169
tb_bool_t tb_thread_setaffinity(tb_thread_ref_t thread, tb_cpuset_ref_t cpuset)

0 commit comments

Comments
 (0)