Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/library_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,10 @@ var LibraryPThread = {
transferredCanvasNames = '{{{ OFFSCREENCANVASES_TO_PTHREAD }}}';
} else
#endif
transferredCanvasNames &&= UTF8ToString(transferredCanvasNames).trim();
transferredCanvasNames &&= transferredCanvasNames.split(',');
{
transferredCanvasNames = UTF8ToString(transferredCanvasNames).trim();
}
transferredCanvasNames = transferredCanvasNames ? transferredCanvasNames.split(',') : [];
#if GL_DEBUG
dbg(`pthread_create: transferredCanvasNames="${transferredCanvasNames}"`);
#endif
Expand Down
17 changes: 17 additions & 0 deletions test/other/test_pthread_hello.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <assert.h>
#include <pthread.h>
#include <stdio.h>

void* thread_func(void* arg) {
printf("Hello from thread\n");
return NULL;
}

int main() {
pthread_t t;
pthread_create(&t, NULL, thread_func, NULL);
assert(t);
pthread_join(t, NULL);
printf("done\n");
return 0;
}
2 changes: 2 additions & 0 deletions test/other/test_pthread_hello.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Hello from thread
done
8 changes: 8 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -12080,6 +12080,14 @@ def test_pthread_reuse(self):
self.set_setting('PTHREAD_POOL_SIZE', 1)
self.do_other_test('test_pthread_reuse.c')

@parameterized({
'': ([],),
'offscreen_canvas': (['-sOFFSCREENCANVAS_SUPPORT', '-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$GL'],),
Copy link
Member

Choose a reason for hiding this comment

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

Why is GL needed? I don't see it used in the test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

From library_pthread.js:

#if ASSERTIONS                                                                   
        assert(typeof GL == 'object', 'OFFSCREENCANVAS_SUPPORT assumes GL is in use (you can force-include it with \'-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$GL\')');
#endif  

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks.

})
@node_pthreads
def test_pthread_hello(self, args):
self.do_other_test('test_pthread_hello.c', args)

@node_pthreads
def test_pthread_relocatable(self):
self.do_run_in_out_file_test('hello_world.c', emcc_args=['-sRELOCATABLE'])
Expand Down
Loading