Skip to content

Commit 7caaa88

Browse files
committed
Make temporaries in the glue script thread safe
This emits all temporaries as 'static thread_local <type> temp;' instead of 'static <type> temp;' and prevents race conditions when you use the resulting library in a multithreaded environment. When compiling without -pthread, the thread_local attribute is ignored and the generated code is as it was before.
1 parent 10cb9d4 commit 7caaa88

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/webidl_binder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ def make_call_args(i):
629629
if non_pointer:
630630
return_prefix += '&'
631631
if copy:
632-
pre += ' static %s temp;\n' % type_to_c(return_type, non_pointing=True)
632+
pre += ' static thread_local %s temp;\n' % type_to_c(return_type, non_pointing=True)
633633
return_prefix += '(temp = '
634634
return_postfix += ', &temp)'
635635

0 commit comments

Comments
 (0)